Skip to content

Commit ce74d52

Browse files
committed
More cleanup
1 parent b44c1d8 commit ce74d52

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

cmd/tools/status_test.go

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,11 @@ import (
66
"slices"
77
"testing"
88

9-
"github.com/go-nv/goenv/internal/utils"
10-
119
"github.com/go-nv/goenv/internal/cmdtest"
1210
"github.com/go-nv/goenv/internal/config"
1311
"github.com/go-nv/goenv/internal/manager"
1412
toolspkg "github.com/go-nv/goenv/internal/tools"
15-
"github.com/go-nv/goenv/testing/testutil"
13+
"github.com/go-nv/goenv/internal/utils"
1614
)
1715

1816
func TestStatusCommand_NoVersions(t *testing.T) {
@@ -255,14 +253,8 @@ func TestStatusCommand_EmptyTools(t *testing.T) {
255253
// Create versions but no tools
256254
versions := []string{"1.21.0", "1.22.0", "1.23.0"}
257255
for _, v := range versions {
258-
versionPath := filepath.Join(tmpDir, "versions", v)
259-
// Create Go binary (required by ListInstalledVersions)
260-
goBinDir := filepath.Join(versionPath, "bin")
261-
if err := utils.EnsureDirWithContext(goBinDir, "create test directory"); err != nil {
262-
t.Fatal(err)
263-
}
264-
goBin := filepath.Join(goBinDir, "go")
265-
testutil.WriteTestFile(t, goBin, []byte("#!/bin/sh\necho go version"), utils.PermFileExecutable)
256+
// Create Go binary using helper (handles .bat on Windows)
257+
cmdtest.CreateTestBinary(t, tmpDir, v, "go")
266258
}
267259

268260
mgr := manager.NewManager(cfg)

cmd/tools/sync_tools_test.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,14 @@ func setupSyncTestEnv(t *testing.T, versions []string, tools map[string][]string
2323
for _, version := range versions {
2424
versionPath := filepath.Join(tmpDir, "versions", version)
2525

26-
// Create go binary directory (manager expects versionPath/go/bin/go)
26+
// Create go binary directory (tools manager expects versionPath/go/bin/go)
2727
goBinDir := filepath.Join(versionPath, "go", "bin")
2828
if err := utils.EnsureDirWithContext(goBinDir, "create test directory"); err != nil {
2929
t.Fatalf("Failed to create go bin directory: %v", err)
3030
}
3131

32-
// Create mock go binary
33-
goBinary := filepath.Join(goBinDir, "go")
34-
var content string
35-
if utils.IsWindows() {
36-
goBinary += ".bat"
37-
content = "@echo off\necho 'mock go'\n"
38-
} else {
39-
content = "#!/bin/sh\necho 'mock go'\n"
40-
}
41-
42-
testutil.WriteTestFile(t, goBinary, []byte(content), utils.PermFileExecutable)
32+
// Create mock go binary using helper (handles .bat on Windows)
33+
cmdtest.CreateToolExecutable(t, goBinDir, "go")
4334

4435
// Create GOPATH/bin directory
4536
gopathBin := filepath.Join(versionPath, "gopath", "bin")

0 commit comments

Comments
 (0)