(t *testing.T)
| 45 | } |
| 46 | |
| 47 | func TestCorsMiddleware_OptionsRequest(t *testing.T) { |
| 48 | var innerCalled bool |
| 49 | inner := http.HandlerFunc(func(_ http.ResponseWriter, _ *http.Request) { |
| 50 | innerCalled = true |
| 51 | }) |
| 52 | |
| 53 | handler := corsMiddleware(inner) |
| 54 | |
| 55 | req := httptest.NewRequest(http.MethodOptions, "/api/tasks", nil) |
| 56 | rec := httptest.NewRecorder() |
| 57 | |
| 58 | handler.ServeHTTP(rec, req) |
| 59 | |
| 60 | if innerCalled { |
| 61 | t.Error("expected inner handler NOT to be called for OPTIONS request") |
| 62 | } |
| 63 | |
| 64 | if rec.Code != http.StatusNoContent { |
| 65 | t.Errorf("expected 204 for OPTIONS, got %d", rec.Code) |
| 66 | } |
| 67 | |
| 68 | origin := rec.Header().Get("Access-Control-Allow-Origin") |
| 69 | if origin != "http://localhost:5173" { |
| 70 | t.Errorf("expected CORS origin header on OPTIONS response, got %q", origin) |
| 71 | } |
| 72 | } |
| 73 | |
| 74 | func TestNewServer_CreatesInstance(t *testing.T) { |
| 75 | dir := createTestTaskDir(t) |
nothing calls this directly
no test coverage detected