Skip to content

Commit

Permalink
Review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kegsay committed Nov 9, 2023
1 parent 4de37c5 commit 03f6287
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion state/migrations/20231108122539_clear_stuck_invites.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func upClearStuckInvites(ctx context.Context, tx *sql.Tx) error {
WHERE room_id NOT IN (
SELECT room_id
FROM syncv3_rooms
) GROUP BY user_id
)
`)
defer rows.Close()
if err != nil {
Expand Down
20 changes: 20 additions & 0 deletions state/migrations/20231108122539_clear_stuck_invites_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,4 +209,24 @@ func TestClearStuckInvites(t *testing.T) {
t.Fatalf("SelectAllInvitesForUser got invites for %s, wanted none: %+v", userID, got)
}
}
// ensure other invites remain
wantInvites := map[string][]string{
alice: {roomA},
charlie: {roomC},
}
for userID, wantInvitesRooms := range wantInvites {
got, err := inviteTable.SelectAllInvitesForUser(userID)
if err != nil {
t.Fatalf("SelectAllInvitesForUser: %s", err)
}
if len(got) != len(wantInvitesRooms) {
t.Fatalf("SelectAllInvitesForUser got %d invites for %s, wanted %d", len(got), userID, len(wantInvitesRooms))
}
for _, wantRoom := range wantInvitesRooms {
_, exists := got[wantRoom]
if !exists {
t.Fatalf("SelectAllInvitesForUser wanted invite for %s in %s, but it's missing", userID, wantRoom)
}
}
}
}

0 comments on commit 03f6287

Please sign in to comment.