Files
silver_pose/v2/internal/store/store_test.go
T
ilaandClaude Opus 4.8 6c779aafb4 feat(v2): T-309 SQLite fall-event persistence (mattn/go-sqlite3)
Persist confirmed fall events to a local SQLite DB under artifacts/:
camera host/port/channel + event id/track/source/config version/state/
latency/screenshot path/confirmed-at. Schema stores no password (guarded
by test). Wire openRecorder/saveRecord into the alerts loop; failures are
non-fatal. Re-applied the SILVER-POSE vendored os_windows.go patch that
go mod vendor reverted.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-23 22:15:55 +08:00

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")
}
}