Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check that filter JSON can be passed inline as a query parameter #103

Merged
merged 3 commits into from
Dec 11, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions tests/31sync/13inline_filter.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
use JSON qw( encode_json );

test "Can pass a JSON filter as a query parameter",
requires => [ local_user_and_room_fixtures() ],

check => sub {
my ( $user, $room_id ) = @_;

matrix_sync( $user, filter => encode_json( {
room => {
state => { types => [ "m.room.member" ] },
timeline => { limit => 0 },
}
}))->then( sub {
my ( $body ) = @_;

my $room = $body->{rooms}{join}{$room_id};

@{ $room->{timeline}{events} } == 0
or die "Expected no timeline events because limit is 0";

@{ $room->{state}{events} } == 1
or die "Expected a single state event because of the filter";

$room->{state}{events}[0]{type} eq "m.room.member"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way, I'm cleaning up eq type tests to use assert_eq instead, as they'll have nicer output on failures.

or die "Expected a single member event because of the filter";

Future->done(1);
});
};