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

Function TestHandleUpdateTask_Body

apps/cli/internal/web/handlers_test.go:553–576  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

551}
552
553func TestHandleUpdateTask_Body(t *testing.T) {
554 dir := createTestTaskDir(t)
555 dp := NewDataProvider(dir, false)
556
557 body := strings.NewReader(`{"body":"# Updated\n\nNew body content."}`)
558 req := httptest.NewRequest(http.MethodPut, "/api/tasks/001", body)
559 req.SetPathValue("id", "001")
560 rec := httptest.NewRecorder()
561
562 handleUpdateTask(dp, false)(rec, req)
563
564 if rec.Code != http.StatusOK {
565 t.Fatalf("expected 200, got %d: %s", rec.Code, rec.Body.String())
566 }
567
568 content, _ := os.ReadFile(filepath.Join(dir, "001-task-one.md"))
569 s := string(content)
570 if !strings.Contains(s, "New body content.") {
571 t.Error("expected new body content in file")
572 }
573 if strings.Contains(s, "# Task One") {
574 t.Error("expected old body to be replaced")
575 }
576}
577
578func TestHandleUpdateTask_Tags(t *testing.T) {
579 dir := createTestTaskDir(t)

Callers

nothing calls this directly

Calls 4

createTestTaskDirFunction · 0.85
NewDataProviderFunction · 0.85
handleUpdateTaskFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected