# This test checks that the package resolution is followed per-package
# rather than per-directory.

-- test0/initial-requirements --
main.test@v0
-- test0/root-packages --
main.test@v0:main
-- test0/default-major-versions --
-- test0/want --
main.test@v0:main
	flags: inAll,isRoot,fromRoot,importsLoaded
	mod: main.test@v0
	external: false
	location: .
	file: main.cue: main
	imports:
		example.com/blah@v0
example.com/blah@v0
	flags: inAll,isRoot,fromRoot
	error: cannot find module providing package example.com/blah@v0
	missing: true
-- test1/initial-requirements --
main.test@v0
example.com@v0.0.1
foo.com/bar@v0.0.1
-- test1/root-packages --
main.test@v0:main
-- test1/default-major-versions --
-- test1/want --
main.test@v0:main
	flags: inAll,isRoot,fromRoot,importsLoaded
	mod: main.test@v0
	external: false
	location: .
	file: main.cue: main
	imports:
		example.com/blah@v0
example.com/blah@v0
	flags: inAll,isRoot,fromRoot,importsLoaded
	mod: example.com@v0.0.1
	external: true
	location: _registry/example.com_v0.0.1/blah
	file: _registry/example.com_v0.0.1/blah/blah.cue: blah
	imports:
		foo.com/bar/hello/goodbye@v0
foo.com/bar/hello/goodbye@v0
	flags: inAll,isRoot,fromRoot,importsLoaded
	mod: foo.com/bar@v0.0.1
	external: true
	location: _registry/foo.com_bar_v0.0.1/hello/goodbye
	file: _registry/foo.com_bar_v0.0.1/hello/goodbye/hello.cue: goodbye
-- main.cue --
package main
import "example.com/blah@v0"
-- cue.mod/module.cue --
module: "main.test@v0"
language: version: "v0.12.0"
-- other/other.cue --
package other
import "example.com/blah:otherpkg"

-- _registry/example.com_v0.0.1/cue.mod/module.cue --
module: "example.com@v0"
language: version: "v0.8.0"
deps: {
	"foo.com/bar/hello@v0": v: "v0.2.3"
	"bar.com@v0": v: "v0.5.0"
}
-- _registry/example.com_v0.0.1/blah/blah.cue --
package blah
import _ "foo.com/bar/hello/goodbye@v0"
-- _registry/example.com_v0.0.1/blah/otherpkg.cue --
package otherpkg
import _ "foo.com/bar/hello/more@v0"

-- _registry/foo.com_bar_v0.0.1/cue.mod/module.cue --
module: "foo.com/bar@v0"
language: version: "v0.8.0"
-- _registry/foo.com_bar_v0.0.1/hello/goodbye/hello.cue --
package goodbye
-- _registry/foo.com_bar_v0.0.1/hello/more
package more
