Skip to content

Commit 3d3b4f7

Browse files
committed
refactor: make copyFile public (internally)
1 parent e33a360 commit 3d3b4f7

File tree

3 files changed

+4
-18
lines changed

3 files changed

+4
-18
lines changed

cmd/osv-scanner/internal/testcmd/copy.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import (
88
"testing"
99
)
1010

11-
func copyFile(from, to string) (string, error) {
11+
func CopyFile(from, to string) (string, error) {
1212
b, err := os.ReadFile(from)
1313
if err != nil {
1414
return "", fmt.Errorf("could not read test file: %w", err)
@@ -37,7 +37,7 @@ func CopyFileFlagTo(t *testing.T, tc Case, flagName string, dir string) string {
3737
return ""
3838
}
3939

40-
newPath, err := copyFile(flagValue, filepath.Join(dir, filepath.Base(flagValue)))
40+
newPath, err := CopyFile(flagValue, filepath.Join(dir, filepath.Base(flagValue)))
4141

4242
if err != nil {
4343
t.Fatalf("%v", err)

cmd/osv-scanner/internal/testcmd/git.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ func SetupGitFixtures() (func(), error) {
4343
}
4444

4545
for _, f := range gitIgnoreFiles {
46-
gitignoreFile, err := copyFile(f, filepath.Join(filepath.Dir(f), ".gitignore"))
46+
gitignoreFile, err := CopyFile(f, filepath.Join(filepath.Dir(f), ".gitignore"))
4747

4848
if err != nil {
4949
return cleaner, err

cmd/osv-scanner/scan/source/command_test.go

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package source_test
22

33
import (
4-
"fmt"
54
"net/http"
65
"os"
76
"path/filepath"
@@ -1718,19 +1717,6 @@ func TestCommand_FlagDeprecatedPackages(t *testing.T) {
17181717
}
17191718
}
17201719

1721-
func copyFile(from, to string) (string, error) {
1722-
b, err := os.ReadFile(from)
1723-
if err != nil {
1724-
return "", fmt.Errorf("could not read test file: %w", err)
1725-
}
1726-
1727-
if err := os.WriteFile(to, b, 0600); err != nil {
1728-
return "", fmt.Errorf("could not copy test file: %w", err)
1729-
}
1730-
1731-
return to, nil
1732-
}
1733-
17341720
func TestCommand_UpdateConfigIgnores(t *testing.T) {
17351721
t.Parallel()
17361722

@@ -1772,7 +1758,7 @@ func TestCommand_UpdateConfigIgnores(t *testing.T) {
17721758
t.Fatal(err)
17731759
}
17741760

1775-
_, err = copyFile("testdata/locks-with-invalid-and-configs/"+file, testDir+"/"+file)
1761+
_, err = testcmd.CopyFile("testdata/locks-with-invalid-and-configs/"+file, testDir+"/"+file)
17761762

17771763
if err != nil {
17781764
t.Fatal(err)

0 commit comments

Comments
 (0)