Skip to content

Commit 93ab8c1

Browse files
Fix tests.
1 parent 1608dbd commit 93ab8c1

File tree

1 file changed

+8
-24
lines changed

1 file changed

+8
-24
lines changed

spaserver_test.go

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package spaserve
22

33
import (
4-
"errors"
54
"io"
65
"net/http"
76
"net/http/httptest"
@@ -10,19 +9,6 @@ import (
109
"testing/fstest"
1110
)
1211

13-
func TestNewSpaServer_ConfigErrors(t *testing.T) {
14-
// Test that configuration errors are propagated
15-
_, err := NewSpaServer(SpaServerConfig{}) // Missing FS
16-
if !errors.Is(err, ErrMissingFS) {
17-
t.Errorf("Expected ErrMissingFS, got %v", err)
18-
}
19-
20-
_, err = NewSpaServer(SpaServerConfig{FS: fstest.MapFS{}, BasePath: "invalid"})
21-
if !errors.Is(err, ErrInvalidBasePath) {
22-
t.Errorf("Expected ErrInvalidBasePath, got %v", err)
23-
}
24-
}
25-
2612
func TestNewSpaServer_Helpers(t *testing.T) {
2713
// Test CreateHtmlScriptTagEnvModifier success
2814
_, err := CreateHtmlScriptTagEnvModifier(map[string]string{}, "VALID_NS")
@@ -59,17 +45,15 @@ func TestNewSpaServer_Integration(t *testing.T) {
5945
},
6046
}
6147

62-
config := SpaServerConfig{
63-
FS: mockFS,
64-
BasePath: "/ui/", // Test with a base path
65-
SpaFallbackPath: "index.html",
66-
Targets: []TargetConfig{
48+
handler, err := NewSpaServer(
49+
mockFS,
50+
WithBasePath("/ui/"),
51+
WithSpaFallbackPath("index.html"),
52+
WithTargets([]TargetConfig{
6753
{TargetFile: "config.json", Modifier: configModifier, CacheResult: true},
68-
},
69-
// Use default logger/error handler
70-
}
71-
72-
handler, err := NewSpaServer(config)
54+
}),
55+
WithHtmlPageWhitelist([]string{"index.html"}),
56+
)
7357
if err != nil {
7458
t.Fatalf("NewSpaServer failed: %v", err)
7559
}

0 commit comments

Comments
 (0)