# Test that we can use a package with an absolute version directly on the command line.
exec cue export foo.com/bar@latest
cmp stdout stdout1-golden

exec cue export foo.com/bar@v0.0.3
cmp stdout stdout2-golden

! exec cue export foo.com/bar@v2
stderr 'imports are unavailable because there is no cue.mod/module.cue file'

exec cue export foo.com/bar@v3.latest
cmp stdout stdout3-golden

# Check we can use it with vet.
! exec cue vet -d self foo.com/bar@v3.latest data.json
cmp stderr stderr4-golden

-- stdout1-golden --
{
    "self": "foo.com_v2.1.0/bar"
}
-- stdout2-golden --
{
    "self": "foo.com_v0.0.3/bar"
}
-- stdout3-golden --
{
    "self": "foo.com_v3.0.2-pre/bar"
}
-- stderr4-golden --
conflicting values "foo.com_v3.0.2-pre/bar" and "wrong":
    .tmp/cache/mod/extract/foo.com@v3.0.2-pre/bar/x.cue:2:7
    ./data.json:1:1
-- data.json --
"wrong"
-- _registry/foo.com_v0.0.2/cue.mod/module.cue --
module: "foo.com@v0"
language: version: "v0.8.0"
-- _registry/foo.com_v0.0.2/bar/x.cue --
package bar
self: "foo.com_v0.0.2/bar"
-- _registry/foo.com_v0.0.3/cue.mod/module.cue --
module: "foo.com@v0"
language: version: "v0.8.0"
-- _registry/foo.com_v0.0.3/bar/x.cue --
package bar
self: "foo.com_v0.0.3/bar"

-- _registry/foo.com_v0.1.0/cue.mod/module.cue --
module: "foo.com@v0"
language: version: "v0.8.0"
-- _registry/foo.com_v0.1.0/bar/x.cue --
package bar
self: "foo.com_v0.1.0/bar"

-- _registry/foo.com_v0.1.4/cue.mod/module.cue --
module: "foo.com@v0"
language: version: "v0.8.0"
-- _registry/foo.com_v0.1.4/bar/x.cue --
package bar
self: "foo.com_v0.1.4/bar"

-- _registry/foo.com_v0.2.0/cue.mod/module.cue --
module: "foo.com@v0"
language: version: "v0.8.0"
-- _registry/foo.com_v0.2.0/bar/x.cue --
package bar
self: "foo.com_v0.2.0/bar"

-- _registry/foo.com_v2.1.0/cue.mod/module.cue --
module: "foo.com@v2"
language: version: "v0.8.0"
-- _registry/foo.com_v2.1.0/bar/x.cue --
package bar
self: "foo.com_v2.1.0/bar"

-- _registry/foo.com_v2.1.1-pre/cue.mod/module.cue --
module: "foo.com@v2"
language: version: "v0.8.0"
-- _registry/foo.com_v2.1.1-pre/bar/x.cue --
package bar
self: "foo.com_v2.1.1/bar"

-- _registry/foo.com_v3.0.2-pre/cue.mod/module.cue --
module: "foo.com@v3"
language: version: "v0.8.0"
-- _registry/foo.com_v3.0.2-pre/bar/x.cue --
package bar
self: "foo.com_v3.0.2-pre/bar"

-- _registry/foo.com_bar_v1.2.3/cue.mod/module.cue --
module: "foo.com/bar@v1"
language: version: "v0.8.0"

-- _registry/foo.com_bar_v1.2.3/baz/x.cue --
package baz
self: "foo.com_bar_v1.2.3/baz"

-- _registry/foo.com_bar_v1.5.0/cue.mod/module.cue --
module: "foo.com/bar@v1"
language: version: "v0.8.0"

-- _registry/foo.com_bar_v1.5.0/baz/x.cue --
package baz
self: "foo.com_bar_v1.5.0/baz"
