1
1
package spaserve
2
2
3
3
import (
4
- "errors"
5
4
"io"
6
5
"net/http"
7
6
"net/http/httptest"
@@ -10,19 +9,6 @@ import (
10
9
"testing/fstest"
11
10
)
12
11
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
-
26
12
func TestNewSpaServer_Helpers (t * testing.T ) {
27
13
// Test CreateHtmlScriptTagEnvModifier success
28
14
_ , err := CreateHtmlScriptTagEnvModifier (map [string ]string {}, "VALID_NS" )
@@ -59,17 +45,15 @@ func TestNewSpaServer_Integration(t *testing.T) {
59
45
},
60
46
}
61
47
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 {
67
53
{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
+ )
73
57
if err != nil {
74
58
t .Fatalf ("NewSpaServer failed: %v" , err )
75
59
}
0 commit comments