@@ -39,17 +39,30 @@ func TestFixtureWithVersions(t *testing.T) {
3939 defer f .Cleanup ()
4040
4141 // Add versions using method chaining
42- f .WithVersions ("1.21.0" , "1.22.0" )
42+ f .WithVersions ("1.21.0" , "1.22.0" , "1.23.0" )
4343
44- // Verify versions were created
45- v1Path := filepath .Join (f .Root , "versions" , "1.21.0" , "bin" , "go" )
46- v2Path := filepath .Join (f .Root , "versions" , "1.22.0" , "bin" , "go" )
44+ // Verify versions were created using ListInstalledVersions
45+ versions , err := f .Manager .ListInstalledVersions ()
46+ if err != nil {
47+ t .Fatalf ("Failed to list installed versions: %v" , err )
48+ }
4749
48- if utils .FileNotExists (v1Path ) {
49- t .Errorf ("Version 1.21.0 binary not created at %s" , v1Path )
50+ expectedVersions := []string {"1.21.0" , "1.22.0" , "1.23.0" }
51+ if len (versions ) != len (expectedVersions ) {
52+ t .Errorf ("Expected %d versions, got %d" , len (expectedVersions ), len (versions ))
5053 }
51- if utils .FileNotExists (v2Path ) {
52- t .Errorf ("Version 1.22.0 binary not created at %s" , v2Path )
54+
55+ for _ , expected := range expectedVersions {
56+ found := false
57+ for _ , v := range versions {
58+ if v == expected {
59+ found = true
60+ break
61+ }
62+ }
63+ if ! found {
64+ t .Errorf ("Expected version %s not found in installed versions" , expected )
65+ }
5366 }
5467}
5568
@@ -60,16 +73,16 @@ func TestFixtureWithTools(t *testing.T) {
6073 f .WithVersions ("1.21.0" ).
6174 WithTools ("1.21.0" , "gopls" , "staticcheck" )
6275
63- // Verify tools were created
76+ // Verify tools were created using FindExecutable (handles .bat/.exe on Windows)
6477 toolDir := filepath .Join (f .Root , "versions" , "1.21.0" , "gopath" , "bin" )
65- goplsPath := filepath .Join (toolDir , "gopls" )
66- staticcheckPath := filepath .Join (toolDir , "staticcheck" )
6778
68- if utils .FileNotExists (goplsPath ) {
69- t .Errorf ("gopls not created at %s" , goplsPath )
79+ goplsPath := filepath .Join (toolDir , "gopls" )
80+ if _ , err := utils .FindExecutable (toolDir , "gopls" ); err != nil {
81+ t .Errorf ("gopls not found in %s: %v" , toolDir , err )
7082 }
71- if utils .FileNotExists (staticcheckPath ) {
72- t .Errorf ("staticcheck not created at %s" , staticcheckPath )
83+
84+ if _ , err := utils .FindExecutable (toolDir , "staticcheck" ); err != nil {
85+ t .Errorf ("staticcheck not found in %s: %v" , toolDir , err )
7386 }
7487}
7588
@@ -184,12 +197,13 @@ func TestToolScenario(t *testing.T) {
184197 // Verify version and tools
185198 f .AssertVersionInstalled ("1.21.0" )
186199
200+ // Verify tools were created using FindExecutable (handles .bat/.exe on Windows)
187201 toolDir := filepath .Join (f .Root , "versions" , "1.21.0" , "gopath" , "bin" )
188- if utils .FileNotExists ( filepath . Join ( toolDir , "gopls" )) {
189- t .Error ("gopls not created in ToolScenario" )
202+ if _ , err := utils .FindExecutable ( toolDir , "gopls" ); err != nil {
203+ t .Errorf ("gopls not created in ToolScenario: %v" , err )
190204 }
191- if utils .FileNotExists ( filepath . Join ( toolDir , "staticcheck" )) {
192- t .Error ("staticcheck not created in ToolScenario" )
205+ if _ , err := utils .FindExecutable ( toolDir , "staticcheck" ); err != nil {
206+ t .Errorf ("staticcheck not created in ToolScenario: %v" , err )
193207 }
194208}
195209
@@ -247,19 +261,19 @@ func TestVersionBuilder(t *testing.T) {
247261 WithGoMod ().
248262 Build ()
249263
250- // Verify binaries
264+ // Verify binaries using FindExecutable (handles .bat/.exe on Windows)
251265 binDir := filepath .Join (f .Root , "versions" , "1.21.0" , "bin" )
252- if utils .FileNotExists ( filepath . Join ( binDir , "go" )) {
253- t .Error ("go binary not created" )
266+ if _ , err := utils .FindExecutable ( binDir , "go" ); err != nil {
267+ t .Errorf ("go binary not created: %v" , err )
254268 }
255- if utils .FileNotExists ( filepath . Join ( binDir , "gofmt" )) {
256- t .Error ("gofmt binary not created" )
269+ if _ , err := utils .FindExecutable ( binDir , "gofmt" ); err != nil {
270+ t .Errorf ("gofmt binary not created: %v" , err )
257271 }
258272
259- // Verify tools
273+ // Verify tools using FindExecutable (handles .bat/.exe on Windows)
260274 toolDir := filepath .Join (f .Root , "versions" , "1.21.0" , "gopath" , "bin" )
261- if utils .FileNotExists ( filepath . Join ( toolDir , "gopls" )) {
262- t .Error ("gopls tool not created" )
275+ if _ , err := utils .FindExecutable ( toolDir , "gopls" ); err != nil {
276+ t .Errorf ("gopls tool not created: %v" , err )
263277 }
264278
265279 // Verify pkg directory
@@ -291,14 +305,14 @@ func TestScenarioBuilder(t *testing.T) {
291305 // Local should override global
292306 f .AssertCurrentVersion ("1.22.0" )
293307
294- // Verify tools
308+ // Verify tools using FindExecutable (handles .bat/.exe on Windows)
295309 toolDir1 := filepath .Join (f .Root , "versions" , "1.21.0" , "gopath" , "bin" )
296- if utils .FileNotExists ( filepath . Join ( toolDir1 , "gopls" )) {
297- t .Error ("gopls not created for 1.21.0" )
310+ if _ , err := utils .FindExecutable ( toolDir1 , "gopls" ); err != nil {
311+ t .Errorf ("gopls not created for 1.21.0: %v" , err )
298312 }
299313
300314 toolDir2 := filepath .Join (f .Root , "versions" , "1.22.0" , "gopath" , "bin" )
301- if utils .FileNotExists ( filepath . Join ( toolDir2 , "staticcheck" )) {
302- t .Error ("staticcheck not created for 1.22.0" )
315+ if _ , err := utils .FindExecutable ( toolDir2 , "staticcheck" ); err != nil {
316+ t .Errorf ("staticcheck not created for 1.22.0: %v" , err )
303317 }
304318}
0 commit comments