41 lines
1.1 KiB
Go
41 lines
1.1 KiB
Go
package postgres
|
|
|
|
import (
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
func TestInitialMigrationContainsLedgerSafetyGuards(t *testing.T) {
|
|
contents, err := migrationFiles.ReadFile("migrations/000001_init.up.sql")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
schema := string(contents)
|
|
for _, required := range []string{
|
|
"amount numeric(38, 18)",
|
|
"idempotency_key text NOT NULL UNIQUE",
|
|
"guard_journal_seal",
|
|
"journal is not balanced per asset",
|
|
"cannot append to a sealed journal",
|
|
"reject_ledger_mutation",
|
|
"journals_one_reversal_idx",
|
|
} {
|
|
if !strings.Contains(schema, required) {
|
|
t.Fatalf("migration is missing %q", required)
|
|
}
|
|
}
|
|
}
|
|
|
|
func TestExplorerFilterMigrationAddsSupportingIndexes(t *testing.T) {
|
|
contents, err := migrationFiles.ReadFile("migrations/000002_explorer_filters.up.sql")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
schema := string(contents)
|
|
for _, required := range []string{"journals_effect_recorded_idx", "lower(effect_kind)", "ledger_accounts_user_owner_idx", "USER_AVAILABLE", "USER_FROZEN"} {
|
|
if !strings.Contains(schema, required) {
|
|
t.Fatalf("explorer filter migration is missing %q", required)
|
|
}
|
|
}
|
|
}
|