df58bc25a3
---ci--- project: orca phase: 3 milestone: v0.3 status: complete requirements: covered: [REQ-022, REQ-030, REQ-032] partial: [] ---/ci--- v0.3 milestone merged to main. Includes all v0.2 work (P08-P10) that was previously on the milestone branch but not yet merged to main, plus the v0.3 completion work (iter.Seq streaming + doctor network/db). v0.2 phases included: P08 (mTLS), P09 (scheduling), P10 (security scan). v0.3 phases: P0 (pre-execution), P1 (iter.Seq streaming), P2 (doctor), P3 (final review+ship). Total: 40 requirements, all complete. No new go.mod dependencies. Full test suite passes under -race. gofmt + go vet clean.
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)
|
|
}
|
|
}
|