Skip to content

Commit 317ad43

Browse files
authored
fix(test): update tarball tests to run on windows (#679)
1 parent 7daf8da commit 317ad43

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

pkg/agentfs/tar_test.go

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"net/http/httptest"
1010
"os"
1111
"path/filepath"
12+
"runtime"
1213
"strings"
1314
"testing"
1415

@@ -79,9 +80,16 @@ func TestUploadTarballFilePermissions(t *testing.T) {
7980
}))
8081
defer mockServer.Close()
8182

82-
err = UploadTarball(tmpDir, mockServer.URL, []string{}, ProjectTypePythonPip)
83-
require.Error(t, err)
84-
require.Contains(t, err.Error(), "permission denied")
83+
// Windows permissions model does not support unix-like file mode permissions
84+
// and creating a file you can't read requires modifying Access Control Lists:
85+
//
86+
// https://learn.microsoft.com/en-us/windows/win32/secauthz/access-control-lists
87+
//
88+
if runtime.GOOS != "windows" {
89+
err = UploadTarball(tmpDir, mockServer.URL, []string{}, ProjectTypePythonPip)
90+
require.Error(t, err)
91+
require.Contains(t, err.Error(), "permission denied")
92+
}
8593

8694
err = os.Remove(restrictedFile)
8795
require.NoError(t, err)
@@ -228,9 +236,9 @@ func TestUploadTarballDeepDirectories(t *testing.T) {
228236

229237
dirs := []string{
230238
"level1",
231-
"level1/level2",
232-
"level1/level2/level3",
233-
"level1/level2/level3/level4",
239+
filepath.Join("level1", "level2"),
240+
filepath.Join("level1", "level2", "level3"),
241+
filepath.Join("level1", "level2", "level3", "level4"),
234242
}
235243

236244
for _, dir := range dirs {
@@ -286,7 +294,7 @@ func TestUploadTarballDeepDirectories(t *testing.T) {
286294
relPath, err := filepath.Rel(tmpDir, f.path)
287295
require.NoError(t, err)
288296
for _, content := range contents {
289-
if content.Name == relPath {
297+
if filepath.ToSlash(content.Name) == filepath.ToSlash(relPath) {
290298
found = true
291299
require.Equal(t, int64(len(f.content)), content.Size, "incorrect file size for %s", relPath)
292300
require.False(t, content.IsDir, "file marked as directory: %s", relPath)
@@ -300,7 +308,7 @@ func TestUploadTarballDeepDirectories(t *testing.T) {
300308
initPath := filepath.Join(dir, "__init__.py")
301309
found := false
302310
for _, content := range contents {
303-
if content.Name == initPath {
311+
if filepath.ToSlash(content.Name) == filepath.ToSlash(initPath) {
304312
found = true
305313
require.Equal(t, int64(0), content.Size, "incorrect file size for %s", initPath)
306314
require.False(t, content.IsDir, "file marked as directory: %s", initPath)

0 commit comments

Comments
 (0)