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

Function TestEngine_UpdateOnExternalChange

apps/cli/internal/sync/engine_test.go:142–183  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

140}
141
142func TestEngine_UpdateOnExternalChange(t *testing.T) {
143 sourceName := "test-update"
144 defer cleanupRegistry(sourceName)
145
146 mock := &mockSource{
147 name: sourceName,
148 tasks: []ExternalTask{
149 {ExternalID: "EXT-1", Title: "Original title", Status: "open"},
150 },
151 }
152 Register(mock)
153
154 dir := t.TempDir()
155 outputDir := filepath.Join(dir, "tasks")
156
157 engine := &Engine{ConfigDir: dir}
158 srcCfg := SourceConfig{
159 Name: sourceName,
160 OutputDir: outputDir,
161 FieldMap: FieldMap{Status: map[string]string{"open": "pending", "closed": "completed"}},
162 }
163
164 // First sync
165 _, err := engine.RunSync(srcCfg)
166 if err != nil {
167 t.Fatalf("first sync error: %v", err)
168 }
169
170 // Update mock data
171 mock.tasks = []ExternalTask{
172 {ExternalID: "EXT-1", Title: "Updated title", Status: "closed"},
173 }
174
175 // Second sync — should update
176 result, err := engine.RunSync(srcCfg)
177 if err != nil {
178 t.Fatalf("second sync error: %v", err)
179 }
180 if len(result.Updated) != 1 {
181 t.Errorf("expected 1 updated, got %d", len(result.Updated))
182 }
183}
184
185func TestEngine_ConflictOnLocalChange(t *testing.T) {
186 sourceName := "test-conflict"

Callers

nothing calls this directly

Calls 3

RunSyncMethod · 0.95
cleanupRegistryFunction · 0.85
RegisterFunction · 0.85

Tested by

no test coverage detected