Skip to content

Commit

Permalink
chore: remove unnecessary copy file test helper
Browse files Browse the repository at this point in the history
Signed-off-by: Brian McGee <[email protected]>
  • Loading branch information
brianmcgee committed Oct 21, 2024
1 parent 782c7a0 commit b5c4ccf
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 24 deletions.
5 changes: 2 additions & 3 deletions cmd/root_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/numtide/treefmt/stats"
"github.com/numtide/treefmt/test"
"github.com/numtide/treefmt/walk"
cp "github.com/otiai10/copy"
"github.com/stretchr/testify/require"
)

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

scriptPath := filepath.Join(binPath, "test-fmt-append")

test.CopyFile(t, sourcePath, scriptPath)
as.NoError(os.Chmod(scriptPath, 0o755))
as.NoError(cp.Copy(sourcePath, scriptPath, cp.Options{AddPermission: 0o755}))

// prepend our test bin directory to PATH
t.Setenv("PATH", binPath+":"+os.Getenv("PATH"))
Expand Down
21 changes: 0 additions & 21 deletions test/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package test

import (
"fmt"
"io"
"os"
"path/filepath"
"testing"
Expand Down Expand Up @@ -124,23 +123,3 @@ func ChangeWorkDir(t *testing.T, dir string) {
t.Fatal(fmt.Errorf("failed to change working directory to %s: %w", dir, err))
}
}

func CopyFile(t *testing.T, sourcePath string, destPath string) {
t.Helper()

source, err := os.Open(sourcePath)
if err != nil {
t.Fatal(err, fmt.Sprintf("failed to open %s", sourcePath))
}
defer source.Close()

dest, err := os.Create(destPath)
if err != nil {
t.Fatal(err, fmt.Sprintf("failed to create %s", sourcePath))
}
defer dest.Close()

if _, err = io.Copy(dest, source); err != nil {
t.Fatal(err, fmt.Sprintf("failed to copy %s to %s", sourcePath, destPath))
}
}

0 comments on commit b5c4ccf

Please sign in to comment.