Files
orca/internal/store/migrate_test.go
T
Jon Chery fa35bfc106 ship(P02): doctor network + db merged into v0.3 milestone
---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
2026-08-01 20:05:12 +00:00

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)
}
}