04d9dccd41
The `orca cert` command (ca-init, gen, show, renew, fingerprint) was fully implemented in internal/cli/cert.go but never registered on rootCmd — unreachable from the CLI. Added init() registration (AD-022). Added cert_test.go (regression) + cert_smoke_test.go (e2e). Added cert_repo_test.go (11 tests) + migration 0007 (UNIQUE serial_hex, I-107). ---ci--- project: orca phase: 1 milestone: v0.7 status: verify requirements: covered: [REQ-053] partial: [] ---/ci---
38 lines
904 B
Go
38 lines
904 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 != "0007_certs_serial_unique.sql" {
|
|
t.Errorf("MigrationVersion = %q, want 0007_certs_serial_unique.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)
|
|
}
|
|
}
|