feat(t224): add incremental freight sync

This commit is contained in:
QiuSW
2026-07-29 00:26:05 +08:00
parent 433db45100
commit c69879650e
35 changed files with 2085 additions and 156 deletions
@@ -34,8 +34,11 @@ func TestClaimsMigrationPreservesHistoryAcrossUpDownUp(t *testing.T) {
if applied, err := runner.Up(ctx); err != nil {
t.Fatalf("initial Up() error = %v", err)
} else if applied != 13 {
t.Fatalf("initial Up() applied = %d, want 13", applied)
} else if applied != 14 {
t.Fatalf("initial Up() applied = %d, want 14", applied)
}
if err := runner.Down(ctx); err != nil {
t.Fatalf("initial Down(v14) error = %v", err)
}
if err := runner.Down(ctx); err != nil {
t.Fatalf("initial Down(v13) error = %v", err)
@@ -68,9 +71,14 @@ func TestClaimsMigrationPreservesHistoryAcrossUpDownUp(t *testing.T) {
seedClaimsHistoricalFixture(t, db)
if applied, err := runner.Up(ctx); err != nil {
t.Fatalf("Up(v5-v13) over historical data error = %v", err)
} else if applied != 9 {
t.Fatalf("Up(v5-v13) applied = %d, want 9", applied)
t.Fatalf("Up(v5-v14) over historical data error = %v", err)
} else if applied != 10 {
t.Fatalf("Up(v5-v14) applied = %d, want 10", applied)
}
assertClaimsHistory(t, db, true)
if err := runner.Down(ctx); err != nil {
t.Fatalf("Down(v14) with compatible history error = %v", err)
}
assertClaimsHistory(t, db, true)
@@ -125,9 +133,9 @@ func TestClaimsMigrationPreservesHistoryAcrossUpDownUp(t *testing.T) {
assertClaimsHistory(t, db, false)
if applied, err := runner.Up(ctx); err != nil {
t.Fatalf("final Up(v4-v13) error = %v", err)
} else if applied != 10 {
t.Fatalf("final Up(v4-v13) applied = %d, want 10", applied)
t.Fatalf("final Up(v4-v14) error = %v", err)
} else if applied != 11 {
t.Fatalf("final Up(v4-v14) applied = %d, want 11", applied)
}
assertClaimsHistory(t, db, true)
}
@@ -363,6 +371,9 @@ func TestClaimsMigrationDownFailsClosedForNewAuditData(t *testing.T) {
t.Fatalf("insert v4 audit event: %v", err)
}
if err := runner.Down(ctx); err != nil {
t.Fatalf("Down(v14) error = %v", err)
}
if err := runner.Down(ctx); err != nil {
t.Fatalf("Down(v13) error = %v", err)
}
@@ -27,8 +27,8 @@ func TestRunnerSupportsUpStatusDownAndIdempotentUp(t *testing.T) {
if err != nil {
t.Fatalf("Up() error = %v", err)
}
if applied != 13 {
t.Fatalf("Up() applied = %d, want 13", applied)
if applied != 14 {
t.Fatalf("Up() applied = %d, want 14", applied)
}
assertStatuses(t, runner, map[int64]bool{
1: true,
@@ -44,6 +44,7 @@ func TestRunnerSupportsUpStatusDownAndIdempotentUp(t *testing.T) {
11: true,
12: true,
13: true,
14: true,
})
applied, err = runner.Up(context.Background())
@@ -70,7 +71,8 @@ func TestRunnerSupportsUpStatusDownAndIdempotentUp(t *testing.T) {
10: true,
11: true,
12: true,
13: false,
13: true,
14: false,
})
applied, err = runner.Up(context.Background())
@@ -94,6 +96,7 @@ func TestRunnerSupportsUpStatusDownAndIdempotentUp(t *testing.T) {
11: true,
12: true,
13: true,
14: true,
})
}