store: scope GetProfile/UpdateProfile to a user_id
Part of per-user profile isolation: profile rows are no longer a global singleton, so every read/write requires the caller's userID. This also requires scoping ListActivities, ListWorkoutKinds, UpsertActivity, CreateWorkoutKind, GetSyncState, UpdateSyncState, and ResetAllSyncedData to userID, plus updating all related tests in the store package.
This commit is contained in:
@@ -8,8 +8,12 @@ import (
|
||||
func TestProfile_DefaultsThenUpdate(t *testing.T) {
|
||||
db := openTestDB(t)
|
||||
ctx := context.Background()
|
||||
userID, err := db.ProvisionUser(ctx, "test-sub", "Default")
|
||||
if err != nil {
|
||||
t.Fatalf("ProvisionUser: %v", err)
|
||||
}
|
||||
|
||||
p, err := db.GetProfile(ctx)
|
||||
p, err := db.GetProfile(ctx, userID)
|
||||
if err != nil {
|
||||
t.Fatalf("GetProfile: %v", err)
|
||||
}
|
||||
@@ -64,11 +68,11 @@ func TestProfile_DefaultsThenUpdate(t *testing.T) {
|
||||
p.MinRepresentativePaceSecPerKm = 600
|
||||
p.MinRepresentativeTimeSeconds = 5
|
||||
|
||||
if err := db.UpdateProfile(ctx, p); err != nil {
|
||||
if err := db.UpdateProfile(ctx, userID, p); err != nil {
|
||||
t.Fatalf("UpdateProfile: %v", err)
|
||||
}
|
||||
|
||||
got, err := db.GetProfile(ctx)
|
||||
got, err := db.GetProfile(ctx, userID)
|
||||
if err != nil {
|
||||
t.Fatalf("GetProfile after update: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user