Skip to content

Commit 1bd6c4d

Browse files
committed
Fix Windows CI test failures
- Use proper file:/// URL format for Windows paths in blob storage tests - Accept both text/javascript and application/javascript MIME types
1 parent 935c881 commit 1bd6c4d

2 files changed

Lines changed: 26 additions & 8 deletions

File tree

internal/server/server_test.go

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,11 +262,11 @@ func TestStaticFiles(t *testing.T) {
262262
defer ts.close()
263263

264264
tests := []struct {
265-
path string
266-
contentType string
265+
path string
266+
contentTypes []string
267267
}{
268-
{"/static/tailwind.js", "text/javascript"},
269-
{"/static/style.css", "text/css"},
268+
{"/static/tailwind.js", []string{"text/javascript", "application/javascript"}},
269+
{"/static/style.css", []string{"text/css"}},
270270
}
271271

272272
for _, tc := range tests {
@@ -279,8 +279,15 @@ func TestStaticFiles(t *testing.T) {
279279
}
280280

281281
contentType := w.Header().Get("Content-Type")
282-
if !strings.Contains(contentType, tc.contentType) {
283-
t.Errorf("%s: expected Content-Type containing %s, got %q", tc.path, tc.contentType, contentType)
282+
found := false
283+
for _, ct := range tc.contentTypes {
284+
if strings.Contains(contentType, ct) {
285+
found = true
286+
break
287+
}
288+
}
289+
if !found {
290+
t.Errorf("%s: expected Content-Type containing one of %v, got %q", tc.path, tc.contentTypes, contentType)
284291
}
285292
}
286293
}

internal/storage/blob_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
"encoding/hex"
88
"errors"
99
"io"
10+
"path/filepath"
11+
"runtime"
1012
"strings"
1113
"testing"
1214
)
@@ -15,7 +17,7 @@ func TestOpenBucket(t *testing.T) {
1517
dir := t.TempDir()
1618
ctx := context.Background()
1719

18-
b, err := OpenBucket(ctx, "file://"+dir)
20+
b, err := OpenBucket(ctx, fileURLFromPath(dir))
1921
if err != nil {
2022
t.Fatalf("OpenBucket failed: %v", err)
2123
}
@@ -247,10 +249,19 @@ func createTestBlob(t *testing.T) *Blob {
247249
dir := t.TempDir()
248250
ctx := context.Background()
249251

250-
b, err := OpenBucket(ctx, "file://"+dir)
252+
b, err := OpenBucket(ctx, fileURLFromPath(dir))
251253
if err != nil {
252254
t.Fatalf("OpenBucket failed: %v", err)
253255
}
254256
t.Cleanup(func() { _ = b.Close() })
255257
return b
256258
}
259+
260+
func fileURLFromPath(path string) string {
261+
if runtime.GOOS == "windows" {
262+
// Windows paths need file:///C:/path format
263+
path = filepath.ToSlash(path)
264+
return "file:///" + path
265+
}
266+
return "file://" + path
267+
}

0 commit comments

Comments
 (0)