(t *testing.T)
| 139 | } |
| 140 | |
| 141 | func TestMountFallback_ServesHTML(t *testing.T) { |
| 142 | dir := createTestTaskDir(t) |
| 143 | s := NewServer(Config{ScanDir: dir}) |
| 144 | |
| 145 | mux := http.NewServeMux() |
| 146 | s.mountFallback(mux) |
| 147 | |
| 148 | req := httptest.NewRequest(http.MethodGet, "/", nil) |
| 149 | rec := httptest.NewRecorder() |
| 150 | |
| 151 | mux.ServeHTTP(rec, req) |
| 152 | |
| 153 | if rec.Code != http.StatusOK { |
| 154 | t.Fatalf("expected 200, got %d", rec.Code) |
| 155 | } |
| 156 | |
| 157 | ct := rec.Header().Get("Content-Type") |
| 158 | if ct != "text/html; charset=utf-8" { |
| 159 | t.Errorf("expected text/html content type, got %q", ct) |
| 160 | } |
| 161 | |
| 162 | body := rec.Body.String() |
| 163 | if !strings.Contains(body, "taskmd") { |
| 164 | t.Error("expected fallback HTML to contain 'taskmd'") |
| 165 | } |
| 166 | if !strings.Contains(body, "No web UI embedded") { |
| 167 | t.Error("expected fallback HTML to mention no embedded UI") |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | func TestMountFallback_NonRootPath(t *testing.T) { |
| 172 | dir := createTestTaskDir(t) |
nothing calls this directly
no test coverage detected