All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
41 lines
1.0 KiB
Go
41 lines
1.0 KiB
Go
package postgres
|
|
|
|
import "testing"
|
|
|
|
func TestWeatherPostgresSchemaShape(t *testing.T) {
|
|
s := PostgresSchema()
|
|
if s.MapEvent == nil {
|
|
t.Fatalf("PostgresSchema().MapEvent is nil")
|
|
}
|
|
|
|
wantTables := map[string]bool{
|
|
tableObservations: true,
|
|
tableObservationPresentWeather: true,
|
|
tableForecasts: true,
|
|
tableForecastPeriods: true,
|
|
tableAlertRuns: true,
|
|
tableAlerts: true,
|
|
tableAlertReferences: true,
|
|
}
|
|
|
|
if len(s.Tables) != len(wantTables) {
|
|
t.Fatalf("PostgresSchema().Tables len = %d, want %d", len(s.Tables), len(wantTables))
|
|
}
|
|
|
|
seenIndexes := map[string]bool{}
|
|
for _, tbl := range s.Tables {
|
|
if !wantTables[tbl.Name] {
|
|
t.Fatalf("unexpected table %q in schema", tbl.Name)
|
|
}
|
|
if tbl.PruneColumn == "" {
|
|
t.Fatalf("table %q missing prune column", tbl.Name)
|
|
}
|
|
for _, idx := range tbl.Indexes {
|
|
if seenIndexes[idx.Name] {
|
|
t.Fatalf("duplicate index name %q", idx.Name)
|
|
}
|
|
seenIndexes[idx.Name] = true
|
|
}
|
|
}
|
|
}
|