11package autobuilder
22
33import (
4- "fmt"
54 "testing"
65
76 "github.com/github/codeql-go/extractor/util"
87)
98
10- func addMinorVersions (t * testing.T , version util.SemVer , count int ) string {
11- t .Helper ()
12-
13- var major , minor int
14- if _ , err := fmt .Sscanf (version .StandardSemVer (), "%d.%d" , & major , & minor ); err != nil {
15- t .Fatalf ("Unable to parse Go version %q: %s" , version , err )
16- }
17- return fmt .Sprintf ("%d.%d" , major , minor + count )
18- }
19-
209func TestGetVersionToInstall (t * testing.T ) {
2110 type inputVersions struct {
2211 modVersion string
2312 envVersion string
2413 }
25- versionAboveMax := addMinorVersions (t , maxGoVersion , 1 )
26- versionTwoAboveMax := addMinorVersions (t , maxGoVersion , 2 )
2714 tests := map [inputVersions ]string {
2815 // getVersionWhenGoModVersionNotFound()
2916 {"" , "" }: maxGoVersion .String (),
@@ -33,13 +20,13 @@ func TestGetVersionToInstall(t *testing.T) {
3320 {"" , "1.20.3" }: "" ,
3421
3522 // getVersionWhenGoModVersionTooHigh()
36- {versionAboveMax , "" }: versionAboveMax ,
37- {versionAboveMax , "1.1" }: versionAboveMax ,
38- {versionAboveMax , minGoVersion .String ()}: versionAboveMax ,
39- {versionAboveMax , maxGoVersion .String ()}: versionAboveMax ,
40- {versionTwoAboveMax , versionAboveMax }: versionTwoAboveMax ,
41- {versionAboveMax , versionAboveMax }: "" ,
42- {versionAboveMax , versionTwoAboveMax }: "" ,
23+ {"9999.0" , "" }: "9999.0" ,
24+ {"9999.0" , "1.1" }: "9999.0" ,
25+ {"9999.0" , minGoVersion .String ()}: "9999.0" ,
26+ {"9999.0" , maxGoVersion .String ()}: "9999.0" ,
27+ {"9999.1" , "9999.0" }: "9999.1" ,
28+ {"9999.0" , "9999.0" }: "" ,
29+ {"9999.0" , "9999.1" }: "" ,
4330
4431 // getVersionWhenGoModVersionTooLow()
4532 {"0.0" , "" }: minGoVersion .String (),
0 commit comments