(t *testing.T)
| 726 | } |
| 727 | |
| 728 | func TestHandleUpdateTask_ReadOnly(t *testing.T) { |
| 729 | dir := createTestTaskDir(t) |
| 730 | dp := NewDataProvider(dir, false) |
| 731 | |
| 732 | body := strings.NewReader(`{"status":"completed"}`) |
| 733 | req := httptest.NewRequest(http.MethodPut, "/api/tasks/001", body) |
| 734 | req.SetPathValue("id", "001") |
| 735 | rec := httptest.NewRecorder() |
| 736 | |
| 737 | handleUpdateTask(dp, true)(rec, req) |
| 738 | |
| 739 | if rec.Code != http.StatusForbidden { |
| 740 | t.Fatalf("expected 403, got %d: %s", rec.Code, rec.Body.String()) |
| 741 | } |
| 742 | |
| 743 | var errResp ErrorResponse |
| 744 | if err := json.Unmarshal(rec.Body.Bytes(), &errResp); err != nil { |
| 745 | t.Fatalf("invalid JSON: %v", err) |
| 746 | } |
| 747 | if errResp.Error != "server is in read-only mode" { |
| 748 | t.Errorf("expected 'server is in read-only mode', got %q", errResp.Error) |
| 749 | } |
| 750 | } |
| 751 | |
| 752 | // GET /api/next tests |
| 753 |
nothing calls this directly
no test coverage detected