@@ -4,11 +4,11 @@ import (
44 "path/filepath"
55 "testing"
66
7+ "github.com/go-nv/goenv/internal/cmdtest"
78 "github.com/go-nv/goenv/internal/config"
89 "github.com/go-nv/goenv/internal/manager"
910 toolspkg "github.com/go-nv/goenv/internal/tools"
1011 "github.com/go-nv/goenv/internal/utils"
11- "github.com/go-nv/goenv/testing/testutil"
1212)
1313
1414// TestMultiVersionToolManagement is a comprehensive integration test
@@ -26,20 +26,15 @@ func TestMultiVersionToolManagement(t *testing.T) {
2626 // Create 3 Go versions
2727 versions := []string {"1.21.0" , "1.22.0" , "1.23.0" }
2828 for _ , v := range versions {
29+ // Create Go binary using helper (handles .bat on Windows)
30+ cmdtest .CreateTestBinary (t , tmpDir , v , "go" )
31+
32+ // Create GOPATH/bin directory
2933 versionPath := filepath .Join (tmpDir , "versions" , v )
30- // Create Go binary (required by ListInstalledVersions)
31- goBinDir := filepath .Join (versionPath , "bin" )
3234 gopath := filepath .Join (versionPath , "gopath" , "bin" )
33- if err := utils .EnsureDirWithContext (goBinDir , "create test directory" ); err != nil {
34- t .Fatalf ("unexpected error: %v" , err )
35- }
3635 if err := utils .EnsureDirWithContext (gopath , "create test directory" ); err != nil {
3736 t .Fatalf ("unexpected error: %v" , err )
3837 }
39-
40- // Create Go binary
41- goBin := filepath .Join (goBinDir , "go" )
42- testutil .WriteTestFile (t , goBin , []byte ("#!/bin/sh\n echo go version" ), utils .PermFileExecutable )
4338 }
4439
4540 // Install different tools in different versions
@@ -52,7 +47,7 @@ func TestMultiVersionToolManagement(t *testing.T) {
5247 for version , tools := range toolInstallations {
5348 binPath := filepath .Join (tmpDir , "versions" , version , "gopath" , "bin" )
5449 for _ , tool := range tools {
55- testutil . WriteTestFile (t , filepath . Join ( binPath , tool ), [] byte ( "fake binary" ), utils . PermFileExecutable , "unexpected error" )
50+ cmdtest . CreateToolExecutable (t , binPath , tool )
5651 }
5752 }
5853
0 commit comments