GET /api/config tests
(t *testing.T)
| 681 | // GET /api/config tests |
| 682 | |
| 683 | func 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 | |
| 707 | func TestHandleConfig_ReadOnly(t *testing.T) { |
| 708 | cfg := Config{ReadOnly: true} |
nothing calls this directly
no test coverage detected