@@ -6,59 +6,74 @@ import (
66 "github.com/stretchr/testify/require"
77)
88
9- func TestStandardLibraryURL (t * testing.T ) {
9+ func TestIsStandardLibraryPath (t * testing.T ) {
1010 for _ , tt := range []struct {
11- input string
12- expected string
13- expectedOk bool
11+ input string
12+ expectedPath string
13+ expectedVersion string
14+ expectedOk bool
1415 }{
1516 {
1617 input : "github.com/grafana/grafana/pkg/frontend/vcs.go" ,
17- expected : "" ,
1818 expectedOk : false ,
1919 },
2020 {
21- input : "/usr/local/go/src/bufio/bufio.go" ,
22- expected : "https://raw.githubusercontent.com/golang/go/master/src/ bufio/bufio.go" ,
23- expectedOk : true ,
21+ input : "/usr/local/go/src/bufio/bufio.go" ,
22+ expectedPath : " bufio/bufio.go" ,
23+ expectedOk : true ,
2424 },
2525 {
26- input : "$GOROOT/src/unicode/utf8/utf8.go" ,
27- expected : "https://raw.githubusercontent.com/golang/go/master/src/ unicode/utf8/utf8.go" ,
28- expectedOk : true ,
26+ input : "$GOROOT/src/unicode/utf8/utf8.go" ,
27+ expectedPath : " unicode/utf8/utf8.go" ,
28+ expectedOk : true ,
2929 },
3030 {
31- input : "fmt/scan.go" ,
32- expected : "https://raw.githubusercontent.com/golang/go/master/src/ fmt/scan.go" ,
33- expectedOk : true ,
31+ input : "fmt/scan.go" ,
32+ expectedPath : " fmt/scan.go" ,
33+ expectedOk : true ,
3434 },
3535 {
36- input : "$GOROOT/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go" ,
37- expected : "https://raw.githubusercontent.com/golang/go/master/src/ vendor/golang.org/x/crypto/cryptobyte/asn1.go" ,
38- expectedOk : true ,
36+ input : "$GOROOT/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go" ,
37+ expectedPath : " vendor/golang.org/x/crypto/cryptobyte/asn1.go" ,
38+ expectedOk : true ,
3939 },
4040 {
41- input : "/usr/local/go/src/vendor/golang.org/x/net/http2/hpack/tables.go" ,
42- expected : "https://raw.githubusercontent.com/golang/go/master/src/ vendor/golang.org/x/net/http2/hpack/tables.go" ,
43- expectedOk : true ,
41+ input : "/usr/local/go/src/vendor/golang.org/x/net/http2/hpack/tables.go" ,
42+ expectedPath : " vendor/golang.org/x/net/http2/hpack/tables.go" ,
43+ expectedOk : true ,
4444 },
4545 {
46- input : "/usr/local/Cellar/go/1.21.3/libexec/src/runtime/netpoll_kqueue.go" ,
47- expected : "https://raw.githubusercontent.com/golang/go/go1.21.3/src/runtime/netpoll_kqueue.go" ,
48- expectedOk : true ,
46+ input : "/usr/local/Cellar/go/1.21.3/libexec/src/runtime/netpoll_kqueue.go" ,
47+ expectedPath : "runtime/netpoll_kqueue.go" ,
48+ expectedVersion : "1.21.3" ,
49+ expectedOk : true ,
4950 },
5051 {
51- input : "/opt/hostedtoolcache/go/1.21.6/x64/src/runtime/mgc.go" ,
52- expected : "https://raw.githubusercontent.com/golang/go/go1.21.6/src/runtime/mgc.go" ,
53- expectedOk : true ,
52+ input : "/opt/hostedtoolcache/go/1.21.6/x64/src/runtime/mgc.go" ,
53+ expectedPath : "runtime/mgc.go" ,
54+ expectedVersion : "1.21.6" ,
55+ expectedOk : true ,
56+ },
57+ {
58+ input : "/Users/pyroscope/.golang/packages/pkg/mod/golang.org/toolchain@v0.0.1-go1.24.6.darwin-arm64/src/runtime/proc.go" ,
59+ expectedPath : "runtime/proc.go" ,
60+ expectedVersion : "1.24.6" ,
61+ expectedOk : true ,
62+ },
63+ {
64+ input : "/Users/christian/.golang/packages/pkg/mod/golang.org/toolchain@v0.0.1-go1.25rc1.darwin-arm64/src/runtime/type.go" ,
65+ expectedPath : "runtime/type.go" ,
66+ expectedVersion : "1.25rc1" ,
67+ expectedOk : true ,
5468 },
5569 } {
5670 t .Run (tt .input , func (t * testing.T ) {
57- actual , ok := StandardLibraryURL (tt .input )
71+ actualPath , actualVersion , ok := IsStandardLibraryPath (tt .input )
5872 if ! tt .expectedOk {
5973 require .False (t , ok )
6074 }
61- require .Equal (t , tt .expected , actual )
75+ require .Equal (t , tt .expectedPath , actualPath )
76+ require .Equal (t , tt .expectedVersion , actualVersion )
6277 })
6378 }
6479}
0 commit comments