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

Function TestSyncCommand_DryRun

apps/cli/internal/cli/sync_test.go:32–68  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30}
31
32func TestSyncCommand_DryRun(t *testing.T) {
33 sourceName := "test-cli-dryrun"
34 defer sync.Unregister(sourceName)
35
36 sync.Register(&cliMockSource{
37 name: sourceName,
38 tasks: []sync.ExternalTask{
39 {ExternalID: "CLI-1", Title: "CLI test task", Status: "open"},
40 },
41 })
42
43 tmpDir := t.TempDir()
44 origDir, _ := os.Getwd()
45 if err := os.Chdir(tmpDir); err != nil {
46 t.Fatal(err)
47 }
48 defer os.Chdir(origDir)
49
50 configContent := "sync:\n sources:\n - name: " + sourceName + "\n output_dir: \"tasks\"\n field_map:\n status:\n open: pending\n"
51 if err := os.WriteFile(filepath.Join(tmpDir, ".taskmd.yaml"), []byte(configContent), 0644); err != nil {
52 t.Fatal(err)
53 }
54
55 syncDryRun = true
56 syncSource = ""
57
58 err := runSync(syncDownCmd, nil)
59 if err != nil {
60 t.Fatalf("unexpected error: %v", err)
61 }
62
63 // No files should be created
64 _, statErr := os.Stat(filepath.Join(tmpDir, "tasks"))
65 if statErr == nil {
66 t.Error("expected no tasks directory in dry-run mode")
67 }
68}
69
70func TestSyncCommand_SourceFilter(t *testing.T) {
71 syncDryRun = false

Callers

nothing calls this directly

Calls 2

runSyncFunction · 0.85
ErrorMethod · 0.80

Tested by

no test coverage detected