Skip to content

Commit b5c4ccf

Browse files
committed
chore: remove unnecessary copy file test helper
Signed-off-by: Brian McGee <[email protected]>
1 parent 782c7a0 commit b5c4ccf

File tree

2 files changed

+2
-24
lines changed

2 files changed

+2
-24
lines changed

cmd/root_test.go

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"github.com/numtide/treefmt/stats"
2222
"github.com/numtide/treefmt/test"
2323
"github.com/numtide/treefmt/walk"
24+
cp "github.com/otiai10/copy"
2425
"github.com/stretchr/testify/require"
2526
)
2627

@@ -933,9 +934,7 @@ func TestCacheBusting(t *testing.T) {
933934
as.NoError(os.Mkdir(binPath, 0o755))
934935

935936
scriptPath := filepath.Join(binPath, "test-fmt-append")
936-
937-
test.CopyFile(t, sourcePath, scriptPath)
938-
as.NoError(os.Chmod(scriptPath, 0o755))
937+
as.NoError(cp.Copy(sourcePath, scriptPath, cp.Options{AddPermission: 0o755}))
939938

940939
// prepend our test bin directory to PATH
941940
t.Setenv("PATH", binPath+":"+os.Getenv("PATH"))

test/test.go

-21
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ package test
22

33
import (
44
"fmt"
5-
"io"
65
"os"
76
"path/filepath"
87
"testing"
@@ -124,23 +123,3 @@ func ChangeWorkDir(t *testing.T, dir string) {
124123
t.Fatal(fmt.Errorf("failed to change working directory to %s: %w", dir, err))
125124
}
126125
}
127-
128-
func CopyFile(t *testing.T, sourcePath string, destPath string) {
129-
t.Helper()
130-
131-
source, err := os.Open(sourcePath)
132-
if err != nil {
133-
t.Fatal(err, fmt.Sprintf("failed to open %s", sourcePath))
134-
}
135-
defer source.Close()
136-
137-
dest, err := os.Create(destPath)
138-
if err != nil {
139-
t.Fatal(err, fmt.Sprintf("failed to create %s", sourcePath))
140-
}
141-
defer dest.Close()
142-
143-
if _, err = io.Copy(dest, source); err != nil {
144-
t.Fatal(err, fmt.Sprintf("failed to copy %s to %s", sourcePath, destPath))
145-
}
146-
}

0 commit comments

Comments
 (0)