Verify timestamps are set in state
(t *testing.T)
| 553 | |
| 554 | // Verify timestamps are set in state |
| 555 | func 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. |
| 596 | func createTaskFile(t *testing.T, dir, id, title string) { |
nothing calls this directly
no test coverage detected