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

Function TestSyncCommand_FullSync

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

Source from the content-addressed store, hash-verified

93}
94
95func TestSyncCommand_FullSync(t *testing.T) {
96 sourceName := "test-cli-fullsync"
97 defer sync.Unregister(sourceName)
98
99 sync.Register(&cliMockSource{
100 name: sourceName,
101 tasks: []sync.ExternalTask{
102 {ExternalID: "FS-1", Title: "Full sync task", Status: "open"},
103 },
104 })
105
106 tmpDir := t.TempDir()
107 origDir, _ := os.Getwd()
108 if err := os.Chdir(tmpDir); err != nil {
109 t.Fatal(err)
110 }
111 defer os.Chdir(origDir)
112
113 configContent := "sync:\n sources:\n - name: " + sourceName + "\n output_dir: \"tasks\"\n field_map:\n status:\n open: pending\n"
114 if err := os.WriteFile(filepath.Join(tmpDir, ".taskmd.yaml"), []byte(configContent), 0644); err != nil {
115 t.Fatal(err)
116 }
117
118 syncDryRun = false
119 syncSource = ""
120
121 err := runSync(syncDownCmd, nil)
122 if err != nil {
123 t.Fatalf("unexpected error: %v", err)
124 }
125
126 // Verify task file was created
127 entries, err := os.ReadDir(filepath.Join(tmpDir, "tasks"))
128 if err != nil {
129 t.Fatalf("failed to read tasks dir: %v", err)
130 }
131 if len(entries) != 1 {
132 t.Errorf("expected 1 task file, got %d", len(entries))
133 }
134}
135
136func TestSyncCommand_SourceFilterMatch(t *testing.T) {
137 sourceName := "test-cli-match"

Callers

nothing calls this directly

Calls 1

runSyncFunction · 0.85

Tested by

no test coverage detected