store: migration 0014 — notification_channels + notification_log
This commit is contained in:
@@ -36,3 +36,36 @@ func TestMigration0013AlertsLastSeen(t *testing.T) {
|
||||
t.Fatalf("alerts.last_seen_at not present after migration; cols=%v", cols)
|
||||
}
|
||||
}
|
||||
|
||||
func TestMigration0014NotificationsTables(t *testing.T) {
|
||||
t.Parallel()
|
||||
dir := t.TempDir()
|
||||
st, err := Open(context.Background(), filepath.Join(dir, "rm.db"))
|
||||
if err != nil {
|
||||
t.Fatalf("open: %v", err)
|
||||
}
|
||||
defer st.Close()
|
||||
|
||||
for _, want := range []string{"notification_channels", "notification_log"} {
|
||||
var n int
|
||||
if err := st.DB().QueryRow(
|
||||
`SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name=?`, want,
|
||||
).Scan(&n); err != nil {
|
||||
t.Fatalf("scan: %v", err)
|
||||
}
|
||||
if n != 1 {
|
||||
t.Errorf("table %q missing after migration", want)
|
||||
}
|
||||
}
|
||||
|
||||
// Sanity: kind CHECK accepts all three v1 kinds.
|
||||
for _, k := range []string{"webhook", "ntfy", "smtp"} {
|
||||
_, err := st.DB().Exec(
|
||||
`INSERT INTO notification_channels (id, kind, name, config, created_at, updated_at)
|
||||
VALUES (?, ?, ?, x'00', '2026-01-01T00:00:00Z', '2026-01-01T00:00:00Z')`,
|
||||
"test-"+k, k, "test-"+k)
|
||||
if err != nil {
|
||||
t.Errorf("insert %q rejected by CHECK: %v", k, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user