Files
codeql/go/extractor/toolchain/toolchain_test.go
Michael B. Gale f6c22d466f Update toolchain_test.go
Co-authored-by: Owen Mansel-Chan <62447351+owen-mc@users.noreply.github.com>
2024-03-28 13:32:02 +00:00

23 lines
619 B
Go

package toolchain
import "testing"
func TestParseGoVersion(t *testing.T) {
tests := map[string]string{
"go version go1.18.9 linux/amd64": "go1.18.9",
"warning: GOPATH set to GOROOT (/usr/local/go) has no effect\ngo version go1.18.9 linux/amd64": "go1.18.9",
}
for input, expected := range tests {
actual := parseGoVersion(input)
if actual != expected {
t.Errorf("Expected parseGoVersion(\"%s\") to be \"%s\", but got \"%s\".", input, expected, actual)
}
}
}
func TestHasGoVersion(t *testing.T) {
if HasGoVersion("1.21") {
t.Error("Expected HasGoVersion(\"1.21\") to be false, but got true")
}
}