1
0
mirror of https://github.com/golang/go synced 2024-11-21 11:14:40 -07:00

cmd/go: add test script for list -m -json

Add test script to check 'go list -m -json' include an Origin.
This commit is contained in:
Kioni 2024-05-31 01:16:25 +09:00
parent 1299733f3b
commit 3bec306587
3 changed files with 94 additions and 1 deletions

View File

@ -197,6 +197,12 @@ func TestQuery(t *testing.T) {
if info.Version != tt.vers {
t.Errorf("Query(_, %q, %q, %q, %v) = %v, want %v", tt.path, tt.query, tt.current, allow, info.Version, tt.vers)
}
if strings.HasPrefix(tt.query, "v") || tt.query == "latest" {
if info.Origin == nil {
t.Errorf("Query(_, %q, %q, %q, %v) = %v, info.Origin is nil", tt.path, tt.query, tt.current, allow, info.Version)
}
}
})
}
}

View File

@ -57,7 +57,7 @@ env GOMODCACHE=$WORK/modcache2
go list -m -json vcs-test.golang.org/git/issue61415.git@latest
cp stdout proxy-latest.json
stdout '"Version": "v0.0.0-20231114180000-08a4fa6bb9c0"'
! stdout '"Origin":'
stdout '"Origin":'
# However, if we list a specific, stable version, we should get
# whatever origin metadata the proxy has for the version.

View File

@ -0,0 +1,87 @@
# Test for #67363: fixes let 'go list -m -json' include an Origin
env GOPROXY=https://proxy.golang.org
go list -m -json golang.org/x/arch@latest
stdout 'Origin'
go list -m -json golang.org/x/benchmarks@latest
stdout 'Origin'
go list -m -json golang.org/x/build@latest
stdout 'Origin'
go list -m -json golang.org/x/crypto@latest
stdout 'Origin'
go list -m -json golang.org/x/debug@latest
stdout 'Origin'
go list -m -json golang.org/x/example@latest
stdout 'Origin'
go list -m -json golang.org/x/exp@latest
stdout 'Origin'
go list -m -json golang.org/x/image@latest
stdout 'Origin'
go list -m -json golang.org/x/mobile@latest
stdout 'Origin'
go list -m -json golang.org/x/mod@latest
stdout 'Origin'
go list -m -json golang.org/x/net@latest
stdout 'Origin'
go list -m -json golang.org/x/oauth2@latest
stdout 'Origin'
go list -m -json golang.org/x/perf@latest
stdout 'Origin'
go list -m -json golang.org/x/pkgsite@latest
stdout 'Origin'
go list -m -json golang.org/x/pkgsite-metrics@latest
stdout 'Origin'
go list -m -json golang.org/x/playground@latest
stdout 'Origin'
go list -m -json golang.org/x/review@latest
stdout 'Origin'
go list -m -json golang.org/x/sync@latest
stdout 'Origin'
go list -m -json golang.org/x/sys@latest
stdout 'Origin'
go list -m -json golang.org/x/term@latest
stdout 'Origin'
go list -m -json golang.org/x/text@latest
stdout 'Origin'
go list -m -json golang.org/x/time@latest
stdout 'Origin'
go list -m -json golang.org/x/tools@latest
stdout 'Origin'
go list -m -json golang.org/x/vgo@latest
stdout 'Origin'
go list -m -json golang.org/x/vuln@latest
stdout 'Origin'
go list -m -json golang.org/x/vulndb@latest
stdout 'Origin'
go list -m -json golang.org/x/website@latest
stdout 'Origin'
go list -m -json golang.org/x/xerrors@latest
stdout 'Origin'