ci / vet-and-test (pull_request) Successful in 47s
Why: a rollback can only be safe when the candidate says which schema it will migrate to and whether older binaries can still read that schema. A new migration that forgets to register that fact must fail the test. Evidence: go test ./internal/store/ ./pkg/identity/ -run 'TestMigrationCompat|TestCapabilities' passed. Impact: version --json and identity capabilities include schema.target and schema.compatFloor. Every migration version is listed in migrationBreaksOldReaders. Current versions do not break old readers, so the floor stays 0. Refs: recovery plan r3.1 D2 Co-authored-by: Cursor <cursoragent@cursor.com>
21 lines
703 B
Go
21 lines
703 B
Go
package store
|
|
|
|
import "testing"
|
|
|
|
func TestMigrationCompatRegistered(t *testing.T) {
|
|
if len(migrationBreaksOldReaders) != len(migrations) {
|
|
t.Fatalf("兼容登记 %d 条,迁移 %d 条", len(migrationBreaksOldReaders), len(migrations))
|
|
}
|
|
for _, m := range migrations {
|
|
if _, ok := migrationBreaksOldReaders[m.version]; !ok {
|
|
t.Fatalf("迁移 v%d %s 未登记是否破坏旧制品读取", m.version, m.name)
|
|
}
|
|
}
|
|
if SchemaTarget() != latestMigrationVersion() {
|
|
t.Fatalf("target=%d latest=%d", SchemaTarget(), latestMigrationVersion())
|
|
}
|
|
if SchemaCompatFloor() < 0 || SchemaCompatFloor() > SchemaTarget() {
|
|
t.Fatalf("compatFloor=%d target=%d", SchemaCompatFloor(), SchemaTarget())
|
|
}
|
|
}
|