Skip to content

Commit 9b7a721

Browse files
committed
remove repoRoot.Write and Read
1 parent 4412b0b commit 9b7a721

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

internal/builder/packages_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ func TestCopyLicenseTextFile_UsesExistingLicenseFile(t *testing.T) {
6363
defer repoRoot.Close()
6464

6565
licensePathRel := filepath.Join("LICENSE.txt")
66-
err = repoRoot.WriteFile(licensePathRel, []byte("existing license"), 0644)
66+
err = os.WriteFile(filepath.Join(repoRoot.Name(), licensePathRel), []byte("existing license"), 0644)
6767
require.NoError(t, err)
6868

6969
// Should not attempt to copy, just return nil
7070
err = copyLicenseTextFile(repoRoot, licensePathRel)
7171
assert.NoError(t, err)
7272

7373
// License file should remain unchanged
74-
content, err := repoRoot.ReadFile(licensePathRel)
74+
content, err := os.ReadFile(filepath.Join(repoRoot.Name(), licensePathRel))
7575
require.NoError(t, err)
7676
assert.Equal(t, "existing license", string(content))
7777

@@ -83,16 +83,16 @@ func TestCopyLicenseTextFile_UsesExistingLicenseFile(t *testing.T) {
8383
require.NoError(t, err)
8484
defer repoRoot.Close()
8585

86-
licensePathRel := filepath.Join("LICENSE.txt")
87-
err = repoRoot.WriteFile(licensePathRel, []byte("existing license"), 0644)
86+
licensePath := filepath.Join(repoRoot.Name(), "LICENSE.txt")
87+
err = os.WriteFile(licensePath, []byte("existing license"), 0644)
8888
require.NoError(t, err)
8989

9090
// Should not attempt to copy, just return nil
91-
err = copyLicenseTextFile(repoRoot, filepath.Join(repoRoot.Name(), licensePathRel))
91+
err = copyLicenseTextFile(repoRoot, licensePath)
9292
assert.NoError(t, err)
9393

9494
// License file should remain unchanged
95-
content, err := repoRoot.ReadFile(licensePathRel)
95+
content, err := os.ReadFile(licensePath)
9696
require.NoError(t, err)
9797
assert.Equal(t, "existing license", string(content))
9898

@@ -127,13 +127,13 @@ func TestCopyLicenseTextFile_UsesExistingLicenseFile(t *testing.T) {
127127
defer repoRoot.Close()
128128

129129
// original license file path
130-
err = repoRoot.WriteFile(licenseTextFileName, []byte("repo license"), 0644)
130+
err = os.WriteFile(filepath.Join(repoRoot.Name(), licenseTextFileName), []byte("repo license"), 0644)
131131
require.NoError(t, err)
132132

133133
err = copyLicenseTextFile(repoRoot, "REPO_LICENSE.txt")
134134
assert.NoError(t, err)
135135

136-
content, err := repoRoot.ReadFile("REPO_LICENSE.txt")
136+
content, err := os.ReadFile(filepath.Join(repoRoot.Name(), "REPO_LICENSE.txt"))
137137
require.NoError(t, err)
138138
assert.Equal(t, "repo license", string(content))
139139
})
@@ -144,15 +144,15 @@ func TestCopyLicenseTextFile_UsesExistingLicenseFile(t *testing.T) {
144144
defer repoRoot.Close()
145145

146146
// original license file path
147-
err = repoRoot.WriteFile("CUSTOM_LICENSE.txt", []byte("repo license"), 0644)
147+
err = os.WriteFile(filepath.Join(repoRoot.Name(), "CUSTOM_LICENSE.txt"), []byte("repo license"), 0644)
148148
require.NoError(t, err)
149149

150150
t.Setenv(repositoryLicenseEnv, "CUSTOM_LICENSE.txt")
151151

152152
err = copyLicenseTextFile(repoRoot, "REPO_LICENSE.txt")
153153
assert.NoError(t, err)
154154

155-
content, err := repoRoot.ReadFile("REPO_LICENSE.txt")
155+
content, err := os.ReadFile(filepath.Join(repoRoot.Name(), "REPO_LICENSE.txt"))
156156
require.NoError(t, err)
157157
assert.Equal(t, "repo license", string(content))
158158
})

0 commit comments

Comments
 (0)