Implement remaining cleanup items prior to the next release
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
All checks were successful
ci/woodpecker/push/build-image Pipeline was successful
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package postgres
|
||||
|
||||
import (
|
||||
"reflect"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
fksinks "gitea.maximumdirect.net/ejr/feedkit/sinks"
|
||||
)
|
||||
|
||||
func TestWeatherPostgresSchemaShape(t *testing.T) {
|
||||
@@ -88,6 +91,28 @@ func TestWeatherPostgresSchemaIncludesWeatherStoryColumns(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestWeatherPostgresSchemaParentTablesStartWithEnvelopeColumns(t *testing.T) {
|
||||
for _, table := range []string{
|
||||
tableObservations,
|
||||
tableForecasts,
|
||||
tableForecastDiscussions,
|
||||
tableWeatherStoryRuns,
|
||||
tableAlertRuns,
|
||||
tableOutlookRuns,
|
||||
} {
|
||||
t.Run(table, func(t *testing.T) {
|
||||
columns := orderedColumnsForTable(t, table)
|
||||
want := parentEnvelopeColumns()
|
||||
if len(columns) < len(want) {
|
||||
t.Fatalf("%s has %d columns, want at least %d", table, len(columns), len(want))
|
||||
}
|
||||
if !reflect.DeepEqual(columns[:len(want)], want) {
|
||||
t.Fatalf("%s envelope prefix = %#v, want %#v", table, columns[:len(want)], want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func assertTablePrimaryKey(t *testing.T, table string, want []string) {
|
||||
t.Helper()
|
||||
for _, tbl := range PostgresSchema().Tables {
|
||||
@@ -121,20 +146,26 @@ func assertTableIndex(t *testing.T, table string, name string, want []string) {
|
||||
t.Fatalf("missing table %q", table)
|
||||
}
|
||||
|
||||
func columnsForTable(t *testing.T, table string) map[string]bool {
|
||||
func orderedColumnsForTable(t *testing.T, table string) []fksinks.PostgresColumn {
|
||||
t.Helper()
|
||||
|
||||
schema := PostgresSchema()
|
||||
for _, tbl := range schema.Tables {
|
||||
if tbl.Name != table {
|
||||
continue
|
||||
if tbl.Name == table {
|
||||
return tbl.Columns
|
||||
}
|
||||
cols := make(map[string]bool, len(tbl.Columns))
|
||||
for _, col := range tbl.Columns {
|
||||
cols[col.Name] = true
|
||||
}
|
||||
return cols
|
||||
}
|
||||
t.Fatalf("missing table %q", table)
|
||||
return nil
|
||||
}
|
||||
|
||||
func columnsForTable(t *testing.T, table string) map[string]bool {
|
||||
t.Helper()
|
||||
|
||||
ordered := orderedColumnsForTable(t, table)
|
||||
cols := make(map[string]bool, len(ordered))
|
||||
for _, col := range ordered {
|
||||
cols[col.Name] = true
|
||||
}
|
||||
return cols
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user