Files
geniusrun/backend/internal/store/syncstate_test.go
Christophe Vila f689f74ae0 Initial commit: smartrun MVP
Garmin run classification and progression tracker. Go backend (MCP
client to mcp-garmin, SQLite store, deterministic rule engine, REST
API) and React/TS frontend (Dashboard, Review Queue, Workout Kinds).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-17 18:33:06 +02:00

32 lines
799 B
Go

package store
import (
"context"
"testing"
)
func TestSyncState_DefaultsAndUpdate(t *testing.T) {
db := openTestDB(t)
ctx := context.Background()
state, err := db.GetSyncState(ctx)
if err != nil {
t.Fatalf("GetSyncState: %v", err)
}
if state.EarliestSyncedDate != nil || state.BackfillComplete {
t.Fatalf("expected fresh DB to have no watermark, got %+v", state)
}
if err := db.UpdateSyncState(ctx, "2023-01-01", true); err != nil {
t.Fatalf("UpdateSyncState: %v", err)
}
state, err = db.GetSyncState(ctx)
if err != nil {
t.Fatalf("GetSyncState after update: %v", err)
}
if state.EarliestSyncedDate == nil || *state.EarliestSyncedDate != "2023-01-01" || !state.BackfillComplete {
t.Fatalf("state after update = %+v, want earliest=2023-01-01 complete=true", state)
}
}