Skip to content

Commit 5e39b9d

Browse files
committed
Windows again
1 parent ce74d52 commit 5e39b9d

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

cmd/tools/tools_integration_test.go

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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\necho 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

internal/tools/manager.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,11 +106,12 @@ func (m *Manager) Install(opts InstallOptions) (*InstallResult, error) {
106106
func (m *Manager) InstallSingleTool(version, packagePath string, verbose bool) error {
107107
versionPath := filepath.Join(m.cfg.Root, "versions", version)
108108
goRoot := filepath.Join(versionPath, "go")
109-
goBin := filepath.Join(goRoot, "bin", "go")
109+
goBinDir := filepath.Join(goRoot, "bin")
110110
gopath := filepath.Join(versionPath, "gopath")
111111

112-
// Check if Go binary exists
113-
if utils.FileNotExists(goBin) {
112+
// Check if Go binary exists (handles .bat/.exe on Windows)
113+
goBin, err := utils.FindExecutable(goBinDir, "go")
114+
if err != nil {
114115
return fmt.Errorf("go binary not found for version %s", version)
115116
}
116117

0 commit comments

Comments
 (0)