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

Function TestRm_DeletesWorklog

apps/cli/internal/cli/rm_test.go:330–361  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

328}
329
330func TestRm_DeletesWorklog(t *testing.T) {
331 tmpDir := t.TempDir()
332 os.WriteFile(filepath.Join(tmpDir, "001-setup.md"), []byte(rmTaskPending), 0644)
333
334 // Create worklog
335 wlDir := filepath.Join(tmpDir, ".worklogs")
336 os.MkdirAll(wlDir, 0755)
337 os.WriteFile(filepath.Join(wlDir, "001.md"), []byte("## 2026-02-08T10:00:00Z\n\nStarted work.\n"), 0644)
338
339 resetRmFlags()
340 taskDir = tmpDir
341 rmForce = true
342
343 output, err := captureRmOutput(t, []string{"001"})
344 if err != nil {
345 t.Fatalf("unexpected error: %v", err)
346 }
347
348 if !strings.Contains(output, "Deleted worklog") {
349 t.Errorf("expected worklog deletion message, got: %s", output)
350 }
351
352 // Worklog file should be gone
353 if _, err := os.Stat(filepath.Join(wlDir, "001.md")); !os.IsNotExist(err) {
354 t.Error("expected worklog file to be deleted")
355 }
356
357 // Empty .worklogs dir should be removed
358 if _, err := os.Stat(wlDir); !os.IsNotExist(err) {
359 t.Error("expected empty .worklogs directory to be removed")
360 }
361}
362
363func TestRm_WorklogDirKeptIfNotEmpty(t *testing.T) {
364 tmpDir := t.TempDir()

Callers

nothing calls this directly

Calls 3

resetRmFlagsFunction · 0.85
captureRmOutputFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected