# 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=false 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
-- 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
-- .gomodproxy/externalmod.test_mixfiles_v1.0.0/.mod --
module externalmod.test/mixfiles

-- .gomodproxy/externalmod.test_mixfiles_v1.0.0/.info --
{"Version":"v1.0.0","Time":"2018-10-22T18:45:39Z"}
-- .gomodproxy/externalmod.test_mixfiles_v1.0.0/go.mod --
// A module which mixes CUE, Go, and other files, to be tested with `cue get go`.

module externalmod.test/mixfiles

-- .gomodproxy/externalmod.test_mixfiles_v1.0.0/aa_first_noextension --
Mix an uninteresting file at the beginning of the directory list
to verify that we don't stop looking at the rest of the files.
-- .gomodproxy/externalmod.test_mixfiles_v1.0.0/code_one.go --
package mixfiles

// Some fruit
const NameOne = "Orange"
-- .gomodproxy/externalmod.test_mixfiles_v1.0.0/code_two.go --
package mixfiles

const NameTwo = "Apple"
-- .gomodproxy/externalmod.test_mixfiles_v1.0.0/config_one.cue --
package mixfiles

Type: "Fruit"
-- .gomodproxy/externalmod.test_mixfiles_v1.0.0/config_two.cue --
package mixfiles

Type: string
-- .gomodproxy/externalmod.test_mixfiles_v1.0.0/zz_last_noextension --
-- .gomodproxy/externalmod.test_imports_v1.0.0/.mod --
module externalmod.test/imports

-- .gomodproxy/externalmod.test_imports_v1.0.0/.info --
{"Version":"v1.0.0","Time":"2018-10-22T18:45:39Z"}
-- .gomodproxy/externalmod.test_imports_v1.0.0/go.mod --
module externalmod.test/imports

-- .gomodproxy/externalmod.test_imports_v1.0.0/root/p.go --
package root

import "externalmod.test/imports/sub1"

type Type struct {
	Sub1 sub1.Type
}
-- .gomodproxy/externalmod.test_imports_v1.0.0/sub1/p.go --
package sub1

import "externalmod.test/imports/sub2"

type Type struct {
	Sub2 sub2.Type
}
-- .gomodproxy/externalmod.test_imports_v1.0.0/sub2/p.go --
package sub2

type Type struct {
	Leaf int
}
