Skip to content

Commit 760ba82

Browse files
committed
Fix unit tests
1 parent a0a8468 commit 760ba82

File tree

1 file changed

+25
-33
lines changed

1 file changed

+25
-33
lines changed

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

Lines changed: 25 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -36,45 +36,37 @@ func TestParseGoVersion(t *testing.T) {
3636

3737
func TestGetVersionToInstall(t *testing.T) {
3838
tests := map[versionInfo]string{
39-
// checkForUnsupportedVersions()
40-
41-
// go.mod version below minGoVersion
42-
{"0.0", true, "1.20.3", true}: "",
43-
{"0.0", true, "9999.0", true}: "",
44-
{"0.0", true, "1.2.2", true}: "",
45-
{"0.0", true, "", false}: "",
46-
// go.mod version above maxGoVersion
47-
{"9999.0", true, "1.20.3", true}: "",
48-
{"9999.0", true, "9999.0.1", true}: "",
49-
{"9999.0", true, "1.1", true}: "",
50-
{"9999.0", true, "", false}: "",
51-
// Go installation found with version below minGoVersion
52-
{"1.20", true, "1.2.2", true}: "1.20",
53-
{"1.11", true, "1.2.2", true}: "1.11",
39+
// getVersionWhenGoModVersionNotFound()
40+
{"", false, "", false}: maxGoVersion,
5441
{"", false, "1.2.2", true}: maxGoVersion,
55-
// Go installation found with version above maxGoVersion
56-
{"1.20", true, "9999.0.1", true}: "1.20",
57-
{"1.11", true, "9999.0.1", true}: "1.11",
58-
{"", false, "9999.0.1", true}: maxGoVersion,
42+
{"", false, "9999.0.1", true}: maxGoVersion,
43+
{"", false, "1.11.13", true}: "",
44+
{"", false, "1.20.3", true}: "",
5945

60-
// checkForVersionsNotFound()
46+
// getVersionWhenGoModVersionTooHigh()
47+
{"9999.0", true, "", false}: maxGoVersion,
48+
{"9999.0", true, "9999.0.1", true}: "",
49+
{"9999.0", true, "1.1", true}: maxGoVersion,
50+
{"9999.0", true, minGoVersion, false}: maxGoVersion,
51+
{"9999.0", true, maxGoVersion, true}: "",
6152

62-
// Go installation not found, go.mod version in supported range
63-
{"1.20", true, "", false}: "1.20",
64-
{"1.11", true, "", false}: "1.11",
65-
// Go installation not found, go.mod not found
66-
{"", false, "", false}: maxGoVersion,
67-
// Go installation found with version in supported range, go.mod not found
68-
{"", false, "1.11.13", true}: "",
69-
{"", false, "1.20.3", true}: "",
70-
71-
// compareVersions()
53+
// getVersionWhenGoModVersionTooLow()
54+
{"0.0", true, "", false}: minGoVersion,
55+
{"0.0", true, "9999.0", true}: minGoVersion,
56+
{"0.0", true, "1.2.2", true}: minGoVersion,
57+
{"0.0", true, "1.20.3", true}: "",
7258

73-
// Go installation found with version in supported range, go.mod version in supported range and go.mod version > go installation version
59+
// getVersionWhenGoModVersionSupported()
60+
{"1.20", true, "", false}: "1.20",
61+
{"1.11", true, "", false}: "1.11",
62+
{"1.20", true, "1.2.2", true}: "1.20",
63+
{"1.11", true, "1.2.2", true}: "1.11",
64+
{"1.20", true, "9999.0.1", true}: "1.20",
65+
{"1.11", true, "9999.0.1", true}: "1.11",
66+
// go.mod version > go installation version
7467
{"1.20", true, "1.11.13", true}: "1.20",
7568
{"1.20", true, "1.12", true}: "1.20",
76-
// Go installation found with version in supported range, go.mod version in supported range and go.mod version <= go installation version
77-
// (Note comparisons ignore the patch version)
69+
// go.mod version <= go installation version (Note comparisons ignore the patch version)
7870
{"1.11", true, "1.20", true}: "",
7971
{"1.11", true, "1.20.3", true}: "",
8072
{"1.20", true, "1.20.3", true}: "",

0 commit comments

Comments
 (0)