# Test that cue get go works when used without the --local flag

# cue get go currently appears to act like a wrapper around go get.
# But this is going to change: "cue get go" will be renamed "cue import go".
# When that change happens, cue import go will assume that all
# required dependencies are present, and fail otherwise.
go get externalmod.test/mixfiles@v1.0.0
go mod tidy

# cue get go
exec cue get go externalmod.test/mixfiles
cmp cue.mod/gen/externalmod.test/mixfiles/code_one_go_gen.cue cue.mod/gen/externalmod.test/mixfiles/code_one_go_gen.cue.golden
cmp cue.mod/gen/externalmod.test/mixfiles/code_two_go_gen.cue cue.mod/gen/externalmod.test/mixfiles/code_two_go_gen.cue.golden
cmp cue.mod/gen/externalmod.test/mixfiles/config_one_gen.cue cue.mod/gen/externalmod.test/mixfiles/config_one_gen.cue.golden
cmp cue.mod/gen/externalmod.test/mixfiles/config_two_gen.cue cue.mod/gen/externalmod.test/mixfiles/config_two_gen.cue.golden

# Verify dependencies are as expected
cmp go.mod go.mod.golden

# Verify that all transitive dependencies are generated properly as well.
# If any are missing, the evaluation would fail to load them.
go get externalmod.test/imports/root@v1.0.0
exec cue get go externalmod.test/imports/root

exec cue vet -c uses_imports_root.cue

-- cue.mod/module.cue --
module: "mod.test/local"
language: version: "v0.9.0"
-- uses_imports_root.cue --
package p

import "externalmod.test/imports/root"

root.#Type & {
    Sub1: Sub2: Leaf: 1
}
-- go.mod --
module mod.test/local

go 1.14
-- go.mod.golden --
module mod.test/local

go 1.14

require externalmod.test/mixfiles v1.0.0
-- cuedeps.go --
// +build cuedeps

package cuedeps

import (
	_ "externalmod.test/mixfiles"
)
-- cue.mod/gen/externalmod.test/mixfiles/code_one_go_gen.cue.golden --
// Code generated by cue get go. DO NOT EDIT.

//cue:generate cue get go externalmod.test/mixfiles

package mixfiles

#NameOne: "Orange"
-- cue.mod/gen/externalmod.test/mixfiles/code_two_go_gen.cue.golden --
// Code generated by cue get go. DO NOT EDIT.

//cue:generate cue get go externalmod.test/mixfiles

package mixfiles

#NameTwo: "Apple"
-- cue.mod/gen/externalmod.test/mixfiles/config_one_gen.cue.golden --
// Code generated by cue get go. DO NOT EDIT.

//cue:generate cue get go externalmod.test/mixfiles

package mixfiles

Type: "Fruit"
-- cue.mod/gen/externalmod.test/mixfiles/config_two_gen.cue.golden --
// Code generated by cue get go. DO NOT EDIT.

//cue:generate cue get go externalmod.test/mixfiles

package mixfiles

Type: string
