Review comments

This commit is contained in:
Kegan Dougal 2023-11-09 10:29:26 +00:00
parent 4de37c51f9
commit 03f62871ef
2 changed files with 21 additions and 1 deletions

View File

@ -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 {

View File

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