# When CUE_REGISTRY is correctly set, packages in the
# pkg, usr and gen directories will be used when they don't conflict with
# other module dependencies.

exec cue export .
cmp stdout expect-stdout

-- expect-stdout --
{
    "e": {
        "a": {
            "remote": true
        }
    },
    "local_pkg": {
        "a": {
            "pkg": true
        }
    },
    "local_pkg_usr": {
        "a": {
            "pkg": true,
            "usr": true
        }
    },
    "local_gen_usr": {
        "a": {
            "gen": true,
            "usr": true
        }
    }
}
-- main.cue --
package main
import (
	"example.com/e"
	local_pkg "example.com/e/local_pkg:x"
	local_pkg_usr "example.com/e/local_pkg_usr:x"
	local_gen_usr "example.com/e/local_gen_usr:x"
)

"e": e
"local_pkg": local_pkg
"local_pkg_usr": local_pkg_usr
"local_gen_usr": local_gen_usr

-- cue.mod/module.cue --
module: "test.org"
language: version: "v0.8.0"
deps: "example.com/e@v0": v: "v0.0.1"

-- cue.mod/pkg/example.com/e/local_pkg/x.cue --
package x
a: pkg: true

-- cue.mod/pkg/example.com/e/local_pkg_usr/x.cue --
package x
a: pkg: true

-- cue.mod/usr/example.com/e/local_pkg_usr/x.cue --
package x
a: usr: true

-- cue.mod/usr/example.com/e/local_gen_usr/x.cue --
package x
a: usr: true

-- cue.mod/gen/example.com/e/local_gen_usr/x.cue --
package x
a: gen: true

-- _registry/example.com_e_v0.0.1/cue.mod/module.cue --
module: "example.com/e@v0"
language: version: "v0.8.0"

-- _registry/example.com_e_v0.0.1/main.cue --
package e

a: remote: true

