fa35bfc106
---ci--- project: orca phase: 2 milestone: v0.3 status: complete requirements: covered: [REQ-032] partial: [] ---/ci--- P02: orca doctor network + db full implementation. - DB(): PRAGMA integrity_check + MigrationVersion (PASS/WARN/FAIL) - Network(): mTLS /healthz probe per peer, 3s timeout, zero peers → WARN - certpaths.DBPath() relocation (D-039, breaks import cycle) - store.MigrationVersion() public API - Deleted NetworkStub/DBStub (D-040) - 7 doctor tests + 1 MigrationVersion test, all pass under -race - 4-layer verification passed
38 lines
892 B
Go
38 lines
892 B
Go
package store
|
|
|
|
import (
|
|
"context"
|
|
"path/filepath"
|
|
"testing"
|
|
)
|
|
|
|
func TestMigrationVersion(t *testing.T) {
|
|
dir := t.TempDir()
|
|
db, err := Open(filepath.Join(dir, "test.db"))
|
|
if err != nil {
|
|
t.Fatalf("open db: %v", err)
|
|
}
|
|
defer db.Close()
|
|
|
|
ctx := context.Background()
|
|
version, err := MigrationVersion(ctx, db)
|
|
if err != nil {
|
|
t.Fatalf("migration version: %v", err)
|
|
}
|
|
if version != "0005_node_capacity.sql" {
|
|
t.Errorf("MigrationVersion = %q, want 0005_node_capacity.sql", version)
|
|
}
|
|
|
|
// Empty the migrations table → should return ("", nil).
|
|
if _, err := db.ExecContext(ctx, "DELETE FROM schema_migrations"); err != nil {
|
|
t.Fatalf("clear migrations: %v", err)
|
|
}
|
|
version, err = MigrationVersion(ctx, db)
|
|
if err != nil {
|
|
t.Fatalf("migration version after clear: %v", err)
|
|
}
|
|
if version != "" {
|
|
t.Errorf("MigrationVersion after clear = %q, want empty", version)
|
|
}
|
|
}
|