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

Function TestEngine_StateTimestamps

apps/cli/internal/sync/engine_test.go:555–593  ·  view source on GitHub ↗

Verify timestamps are set in state

(t *testing.T)

Source from the content-addressed store, hash-verified

553
554// Verify timestamps are set in state
555func TestEngine_StateTimestamps(t *testing.T) {
556 sourceName := "test-timestamps"
557 defer cleanupRegistry(sourceName)
558
559 setupMockSource(sourceName, []ExternalTask{
560 {ExternalID: "EXT-1", Title: "A task", Status: "open"},
561 })
562
563 dir := t.TempDir()
564 outputDir := filepath.Join(dir, "tasks")
565
566 before := time.Now().Add(-time.Second)
567
568 engine := &Engine{ConfigDir: dir}
569 srcCfg := SourceConfig{
570 Name: sourceName,
571 OutputDir: outputDir,
572 FieldMap: FieldMap{Status: map[string]string{"open": "pending"}},
573 }
574
575 _, err := engine.RunSync(srcCfg)
576 if err != nil {
577 t.Fatalf("unexpected error: %v", err)
578 }
579
580 state, err := LoadState(dir, sourceName)
581 if err != nil {
582 t.Fatalf("failed to load state: %v", err)
583 }
584
585 if state.LastSync.Before(before) {
586 t.Error("expected LastSync to be recent")
587 }
588
589 ts := state.Tasks["EXT-1"]
590 if ts.LastSynced.Before(before) {
591 t.Error("expected task LastSynced to be recent")
592 }
593}
594
595// createTaskFile creates a minimal task file that the scanner can discover.
596func createTaskFile(t *testing.T, dir, id, title string) {

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected