Skip to content

Commit 1ef1d63

Browse files
committed
Add test for parseGoVersion
1 parent 9af9b32 commit 1ef1d63

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

go/extractor/cli/go-autobuilder/go-autobuilder_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,16 @@ func TestGetImportPathFromRepoURL(t *testing.T) {
2020
}
2121
}
2222
}
23+
24+
func TestParseGoVersion(t *testing.T) {
25+
tests := map[string]string{
26+
"go version go1.18.9 linux/amd64": "go1.18.9",
27+
"warning: GOPATH set to GOROOT (/usr/local/go) has no effect\ngo version go1.18.9 linux/amd64": "go1.18.9",
28+
}
29+
for input, expected := range tests {
30+
actual := parseGoVersion(input)
31+
if actual != expected {
32+
t.Errorf("Expected parseGoVersion(\"%s\") to be \"%s\", but got \"%s\".", input, expected, actual)
33+
}
34+
}
35+
}

0 commit comments

Comments
 (0)