feat(t214): persist candidate observation identities

This commit is contained in:
QiuSW
2026-07-28 12:21:55 +08:00
parent acd3c85b5b
commit 56e7a2be33
29 changed files with 622 additions and 94 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 != 6 {
t.Fatalf("initial Up() applied = %d, want 6", applied)
} else if applied != 7 {
t.Fatalf("initial Up() applied = %d, want 7", applied)
}
if err := runner.Down(ctx); err != nil {
t.Fatalf("initial Down(v7) error = %v", err)
}
if err := runner.Down(ctx); err != nil {
t.Fatalf("initial Down(v6) error = %v", err)
@@ -47,9 +50,14 @@ func TestClaimsMigrationPreservesHistoryAcrossUpDownUp(t *testing.T) {
seedClaimsHistoricalFixture(t, db)
if applied, err := runner.Up(ctx); err != nil {
t.Fatalf("Up(v5-v6) over historical data error = %v", err)
} else if applied != 2 {
t.Fatalf("Up(v5-v6) applied = %d, want 2", applied)
t.Fatalf("Up(v5-v7) over historical data error = %v", err)
} else if applied != 3 {
t.Fatalf("Up(v5-v7) applied = %d, want 3", applied)
}
assertClaimsHistory(t, db, true)
if err := runner.Down(ctx); err != nil {
t.Fatalf("Down(v7) with compatible history error = %v", err)
}
assertClaimsHistory(t, db, true)
@@ -69,9 +77,9 @@ func TestClaimsMigrationPreservesHistoryAcrossUpDownUp(t *testing.T) {
assertClaimsHistory(t, db, false)
if applied, err := runner.Up(ctx); err != nil {
t.Fatalf("final Up(v4-v6) error = %v", err)
} else if applied != 3 {
t.Fatalf("final Up(v4-v6) applied = %d, want 3", applied)
t.Fatalf("final Up(v4-v7) error = %v", err)
} else if applied != 4 {
t.Fatalf("final Up(v4-v7) applied = %d, want 4", applied)
}
assertClaimsHistory(t, db, true)
}
@@ -307,6 +315,9 @@ func TestClaimsMigrationDownFailsClosedForNewAuditData(t *testing.T) {
t.Fatalf("insert v4 audit event: %v", err)
}
if err := runner.Down(ctx); err != nil {
t.Fatalf("Down(v7) error = %v", err)
}
if err := runner.Down(ctx); err != nil {
t.Fatalf("Down(v6) error = %v", err)
}
@@ -27,8 +27,8 @@ func TestRunnerSupportsUpStatusDownAndIdempotentUp(t *testing.T) {
if err != nil {
t.Fatalf("Up() error = %v", err)
}
if applied != 6 {
t.Fatalf("Up() applied = %d, want 6", applied)
if applied != 7 {
t.Fatalf("Up() applied = %d, want 7", applied)
}
assertStatuses(t, runner, map[int64]bool{
1: true,
@@ -37,6 +37,7 @@ func TestRunnerSupportsUpStatusDownAndIdempotentUp(t *testing.T) {
4: true,
5: true,
6: true,
7: true,
})
applied, err = runner.Up(context.Background())
@@ -56,7 +57,8 @@ func TestRunnerSupportsUpStatusDownAndIdempotentUp(t *testing.T) {
3: true,
4: true,
5: true,
6: false,
6: true,
7: false,
})
applied, err = runner.Up(context.Background())
@@ -73,6 +75,7 @@ func TestRunnerSupportsUpStatusDownAndIdempotentUp(t *testing.T) {
4: true,
5: true,
6: true,
7: true,
})
}