Stage 10: admin console & dictionary ops (complaint review, hot-reload, broadcasts) (#11)
Tests · Go / test (push) Successful in 7s
Tests · Integration / integration (push) Successful in 13s

This commit was merged in pull request #11.
This commit is contained in:
2026-06-04 07:27:49 +00:00
parent 4c4beace85
commit 3a640a17a4
49 changed files with 2548 additions and 200 deletions
@@ -0,0 +1,45 @@
package connectsrv_test
import (
"net/http"
"net/http/httptest"
"testing"
"scrabble/gateway/internal/connectsrv"
)
// TestHTTPHandlerMountsAdminConsole verifies the admin proxy is reachable at /_gm/
// through the h2c-wrapped edge mux when configured.
func TestHTTPHandlerMountsAdminConsole(t *testing.T) {
stub := http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
w.WriteHeader(http.StatusTeapot)
})
srv := connectsrv.NewServer(connectsrv.Deps{AdminProxy: stub})
front := httptest.NewServer(srv.HTTPHandler())
defer front.Close()
resp, err := http.Get(front.URL + "/_gm/")
if err != nil {
t.Fatal(err)
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusTeapot {
t.Fatalf("/_gm status = %d, want 418 (routed to the admin proxy)", resp.StatusCode)
}
}
// TestHTTPHandlerNoAdminConsole verifies /_gm is not served when no proxy is set.
func TestHTTPHandlerNoAdminConsole(t *testing.T) {
srv := connectsrv.NewServer(connectsrv.Deps{})
front := httptest.NewServer(srv.HTTPHandler())
defer front.Close()
resp, err := http.Get(front.URL + "/_gm/")
if err != nil {
t.Fatal(err)
}
defer func() { _ = resp.Body.Close() }()
if resp.StatusCode != http.StatusNotFound {
t.Fatalf("/_gm status = %d, want 404 (no admin proxy)", resp.StatusCode)
}
}