MCPcopy Create free account
hub / github.com/driangle/taskmd / TestHandleConfig

Function TestHandleConfig

apps/cli/internal/web/handlers_test.go:683–705  ·  view source on GitHub ↗

GET /api/config tests

(t *testing.T)

Source from the content-addressed store, hash-verified

681// GET /api/config tests
682
683func TestHandleConfig(t *testing.T) {
684 cfg := Config{ReadOnly: false, Version: "1.2.3-abc1234"}
685
686 req := httptest.NewRequest(http.MethodGet, "/api/config", nil)
687 rec := httptest.NewRecorder()
688
689 handleConfig(cfg)(rec, req)
690
691 if rec.Code != http.StatusOK {
692 t.Fatalf("expected 200, got %d", rec.Code)
693 }
694
695 var resp ConfigResponse
696 if err := json.Unmarshal(rec.Body.Bytes(), &resp); err != nil {
697 t.Fatalf("invalid JSON: %v", err)
698 }
699 if resp.ReadOnly {
700 t.Error("expected readonly to be false")
701 }
702 if resp.Version != "1.2.3-abc1234" {
703 t.Errorf("expected version '1.2.3-abc1234', got %q", resp.Version)
704 }
705}
706
707func TestHandleConfig_ReadOnly(t *testing.T) {
708 cfg := Config{ReadOnly: true}

Callers

nothing calls this directly

Calls 2

handleConfigFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected