Skip to content

Commit

Permalink
Fix failures with empty room keys.
Browse files Browse the repository at this point in the history
Signed-off-by: Nicolas Werner <nicolas.werner@hotmail.de>
  • Loading branch information
deepbluev7 committed May 1, 2021
1 parent d0de4de commit 5d840b5
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
21 changes: 15 additions & 6 deletions tests/30rooms/06invite.pl
Original file line number Diff line number Diff line change
Expand Up @@ -159,8 +159,11 @@ sub invited_user_can_reject_invite

# Check that invitee no longer sees the invite

assert_json_object( $body->{rooms}{invite} );
keys %{ $body->{rooms}{invite} } and die "Expected empty dictionary";
if( exists $body->{rooms} and exists $body->{rooms}{invite} ) {
assert_json_object( $body->{rooms}{invite} );
keys %{ $body->{rooms}{invite} } and die "Expected empty dictionary";
}

Future->done(1);
});
}
Expand Down Expand Up @@ -203,8 +206,10 @@ sub invited_user_can_reject_invite_for_empty_room

# Check that invitee no longer sees the invite

assert_json_object( $body->{rooms}{invite} );
keys %{ $body->{rooms}{invite} } and die "Expected empty dictionary";
if( exists $body->{rooms} and exists $body->{rooms}{invite} ) {
assert_json_object( $body->{rooms}{invite} );
keys %{ $body->{rooms}{invite} } and die "Expected empty dictionary";
}
Future->done(1);
});
}
Expand Down Expand Up @@ -235,8 +240,12 @@ sub invited_user_can_reject_invite_for_empty_room
my ( $body ) = @_;

log_if_fail "Sync body", $body;
assert_json_object( $body->{rooms}{invite} );
keys %{ $body->{rooms}{invite} } and die "Expected empty dictionary";

if( exists $body->{rooms} and exists $body->{rooms}{invite} ) {
assert_json_object( $body->{rooms}{invite} );
keys %{ $body->{rooms}{invite} } and die "Expected empty dictionary";
}

Future->done(1);
});
};
Expand Down
8 changes: 5 additions & 3 deletions tests/31sync/09archived.pl
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,12 @@
})->then( sub {
my ( $body ) = @_;

my $leave = $body->{rooms}{leave};
if( exists $body->{rooms} and exists $body->{rooms}{leave} ) {
my $leave = $body->{rooms}{leave};

assert_json_object( $leave );
keys %$leave == 0 or die "Expected no rooms in 'leave' state";
assert_json_object( $leave );
keys %$leave == 0 or die "Expected no rooms in 'leave' state";
}

Future->done(1);
});
Expand Down
6 changes: 4 additions & 2 deletions tests/31sync/15lazy-members.pl
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,10 @@
matrix_sync_again( $alice, filter => $filter_id );
})->then( sub {
my ( $body ) = @_;
my $joined_rooms = $body->{rooms}{join};
assert_deeply_eq($joined_rooms, {});
if( exists $body->{rooms} and exists $body->{rooms}{join} ) {
my $joined_rooms = $body->{rooms}{join};
assert_deeply_eq($joined_rooms, {});
}
Future->done(1);
});
};
Expand Down

0 comments on commit 5d840b5

Please sign in to comment.