Files
restic-manager/internal/store/migrate_test.go
T

34 lines
716 B
Go

package store
import (
"context"
"path/filepath"
"testing"
)
func TestMigration0013AlertsLastSeen(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()
// Column must exist after migration. Best signal: PRAGMA table_info.
rows, err := st.DB().Query(`SELECT name FROM pragma_table_info('alerts')`)
if err != nil {
t.Fatalf("pragma: %v", err)
}
defer rows.Close()
cols := map[string]bool{}
for rows.Next() {
var n string
_ = rows.Scan(&n)
cols[n] = true
}
if !cols["last_seen_at"] {
t.Fatalf("alerts.last_seen_at not present after migration; cols=%v", cols)
}
}