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

Function TestEngine_DryRun

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

Source from the content-addressed store, hash-verified

356}
357
358func TestEngine_DryRun(t *testing.T) {
359 sourceName := "test-dryrun"
360 defer cleanupRegistry(sourceName)
361
362 setupMockSource(sourceName, []ExternalTask{
363 {ExternalID: "EXT-1", Title: "A task", Status: "open"},
364 })
365
366 dir := t.TempDir()
367 outputDir := filepath.Join(dir, "tasks")
368
369 engine := &Engine{ConfigDir: dir, DryRun: true}
370 srcCfg := SourceConfig{
371 Name: sourceName,
372 OutputDir: outputDir,
373 FieldMap: FieldMap{Status: map[string]string{"open": "pending"}},
374 }
375
376 result, err := engine.RunSync(srcCfg)
377 if err != nil {
378 t.Fatalf("unexpected error: %v", err)
379 }
380
381 if len(result.Created) != 1 {
382 t.Errorf("expected 1 created, got %d", len(result.Created))
383 }
384
385 // Verify no files were created
386 entries, err := os.ReadDir(dir)
387 if err != nil {
388 t.Fatalf("failed to read dir: %v", err)
389 }
390 for _, e := range entries {
391 if e.Name() == "tasks" {
392 t.Error("expected no tasks directory in dry-run mode")
393 }
394 }
395
396 // Verify no state was saved
397 state, err := LoadState(dir, sourceName)
398 if err != nil {
399 t.Fatalf("failed to load state: %v", err)
400 }
401 if len(state.Tasks) != 0 {
402 t.Errorf("expected empty state in dry-run mode, got %d tasks", len(state.Tasks))
403 }
404}
405
406func TestEngine_UnknownSource(t *testing.T) {
407 dir := t.TempDir()

Callers

nothing calls this directly

Calls 6

RunSyncMethod · 0.95
cleanupRegistryFunction · 0.85
setupMockSourceFunction · 0.85
LoadStateFunction · 0.85
ErrorMethod · 0.80
NameMethod · 0.65

Tested by

no test coverage detected