34 lines
1.0 KiB
Go
34 lines
1.0 KiB
Go
package httpapi
|
|
|
|
import (
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
|
|
"git.send.nrw/sendnrw/dockwatch/internal/audit"
|
|
"git.send.nrw/sendnrw/dockwatch/internal/auth"
|
|
"git.send.nrw/sendnrw/dockwatch/internal/config"
|
|
)
|
|
|
|
func TestRouterPatternsDoNotConflict(t *testing.T) {
|
|
defer func() {
|
|
if r := recover(); r != nil {
|
|
t.Fatalf("ServeMux route conflict: %v", r)
|
|
}
|
|
}()
|
|
_ = New(config.Config{Mode: config.ModeStandalone}, &auth.Service{}, nil, nil, nil, (*audit.Service)(nil), nil, nil, nil)
|
|
}
|
|
|
|
func TestStaticAssetsDisableBrowserCaching(t *testing.T) {
|
|
h := New(config.Config{Mode: config.ModeStandalone}, &auth.Service{}, nil, nil, nil, (*audit.Service)(nil), nil, nil, nil)
|
|
for _, path := range []string{"/", "/app.js", "/styles.css"} {
|
|
t.Run(strings.TrimPrefix(path, "/"), func(t *testing.T) {
|
|
rr := httptest.NewRecorder()
|
|
h.ServeHTTP(rr, httptest.NewRequest("GET", path, nil))
|
|
if got := rr.Header().Get("Cache-Control"); got != "no-store" {
|
|
t.Fatalf("Cache-Control for %s = %q, want no-store", path, got)
|
|
}
|
|
})
|
|
}
|
|
}
|