42 lines
951 B
Go
42 lines
951 B
Go
package store
|
|||
|
|
|
||
|
|
import (
|
||
|
|
"path/filepath"
|
||
|
|
"strings"
|
||
|
|
"testing"
|
||
|
|
)
|
||
|
|
|
||
|
|
func TestSaveAndCount(t *testing.T) {
|
||
|
|
database, err := Open(filepath.Join(t.TempDir(), "fall.db"))
|
||
|
|
if err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
defer database.Close()
|
||
|
|
|
||
|
|
record := Record{
|
||
|
|
EventID: "FALL-1", TrackID: "P-1", SourceID: "cam",
|
||
|
|
CameraHost: "192.0.2.10", CameraPort: 554, CameraChannel: "102",
|
||
|
|
ConfigVersion: "cfg-x", State: "CONFIRMED", LatencySeconds: 1.8,
|
||
|
|
ScreenshotPath: "20260723/FALL-1.png", ConfirmedAtUTC: "2026-07-23T12:00:00Z",
|
||
|
|
}
|
||
|
|
if err := database.Save(record); err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
if err := database.Save(record); err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
count, err := database.Count()
|
||
|
|
if err != nil {
|
||
|
|
t.Fatal(err)
|
||
|
|
}
|
||
|
|
if count != 2 {
|
||
|
|
t.Fatalf("count = %d, want 2", count)
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
func TestSchemaHasNoPasswordColumn(t *testing.T) {
|
||
|
|
if strings.Contains(strings.ToLower(schema), "password") {
|
||
|
|
t.Fatal("fall_events schema must not store a password")
|
||
|
|
}
|
||
|
|
}
|