Skip to content

Commit fecac51

Browse files
Override StaticDir in main_test.go for consistent test setup
Updated cmd/server/main_test.go with: - Modified setupRouter to set config.StaticDir to "../../static" using filepath.Join - Ensures static file serving points to root-level static/ during tests - Added path/filepath import Maintains test reliability with configurable static directory in main.go.
1 parent 9d61486 commit fecac51

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cmd/server/main_test.go

+2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"net/http"
55
"net/http/httptest"
66
"net/url"
7+
"path/filepath"
78
"strings"
89
"testing"
910

@@ -19,6 +20,7 @@ func setupRouter(t *testing.T) *gin.Engine {
1920
if err != nil {
2021
t.Fatalf("Failed to load config: %v", err)
2122
}
23+
config.StaticDir = filepath.Join("..", "..", "static")
2224
r, err := SetupRouter(config)
2325
if err != nil {
2426
t.Fatalf("Failed to setup router: %v", err)

0 commit comments

Comments
 (0)