Test switching branch on paths

This commit is contained in:
Melon 2025-03-30 00:01:13 +00:00
parent 912f1b2e03
commit ccfac033df
Signed by: melon
GPG Key ID: 6C9D970C50D26A25

View File

@ -45,10 +45,11 @@ func TestHandler_ServeHTTP(t *testing.T) {
serveTest(t, "example.com/hello-world", branch, "example.com/@"+branch+"/hello-world")
})
for _, testPath := range []string{"/", "/posts/test", "/this-is-definitely-a-page-that-I-really-need-to-view-right-now"} {
t.Run("switch to "+branch+" branch", func(t *testing.T) {
h := New(afero.NewMemMapFs(), &fakeServeDB{})
req := httptest.NewRequest(http.MethodGet, httpPrefix+"example.com/?__bluebell-switch-beta="+branch, nil)
req := httptest.NewRequest(http.MethodGet, httpPrefix+"example.com"+testPath+"?__bluebell-switch-beta="+branch, nil)
rec := httptest.NewRecorder()
h.ServeHTTP(rec, req)
@ -70,6 +71,7 @@ func TestHandler_ServeHTTP(t *testing.T) {
})
}
}
}
func serveTest(t *testing.T, address string, branch string, name string) {
t.Run(fmt.Sprintf("serveTest \"%s\" (%s) -> \"%s\"", address, branch, name), func(t *testing.T) {