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

Function TestMountFallback_ServesHTML

apps/cli/internal/web/server_test.go:141–169  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

139}
140
141func 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
171func TestMountFallback_NonRootPath(t *testing.T) {
172 dir := createTestTaskDir(t)

Callers

nothing calls this directly

Calls 5

mountFallbackMethod · 0.95
createTestTaskDirFunction · 0.85
ServeHTTPMethod · 0.80
ErrorMethod · 0.80
NewServerFunction · 0.70

Tested by

no test coverage detected