-
Notifications
You must be signed in to change notification settings - Fork 55
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
add and update tests for new behaviour with empty backups #519
Changes from 3 commits
d95a50a
5d00839
32875e1
74299c6
403f4f8
794136b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
my $fixture = local_user_fixture(); | ||
|
||
my $current_version; # FIXME: is there a better way of passing the backup version between tests? | ||
|
||
test "Can create backup version", | ||
requires => [ $fixture ], | ||
|
||
|
@@ -40,6 +38,44 @@ | |
}); | ||
}; | ||
|
||
test "Responds correctly when backup is empty", | ||
requires => [ $fixture, qw( can_create_backup_version ) ], | ||
|
||
do => sub { | ||
my ( $user ) = @_; | ||
my $version; | ||
|
||
matrix_get_key_backup_info( $user )->then( sub { | ||
my ( $content ) = @_; | ||
|
||
log_if_fail "Content", $content; | ||
|
||
$version = $content->{version}; | ||
|
||
matrix_get_backup_key( $user, '!notaroom', 'notassession', $version); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. missing a space before the |
||
})->main::expect_http_4xx | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why is this a 4xx rather than something more specific? Also, please can we have a comment to say what we are testing here? |
||
->then( sub { | ||
matrix_get_backup_key( $user, '!notaroom', '', $version); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, it would be useful to have some more words to explain what we are testing and what we expect the result to be. |
||
})->then( sub { | ||
my ( $content ) = @_; | ||
|
||
log_if_fail "Content", $content; | ||
|
||
assert_deeply_eq( $content, {"sessions" => {}}); | ||
|
||
matrix_get_backup_key( $user, '', '', $version ); | ||
})->then( sub { | ||
my ( $content ) = @_; | ||
|
||
log_if_fail "Content", $content; | ||
|
||
assert_deeply_eq( $content, {"rooms" => {}}); | ||
|
||
Future->done(1); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we don't need this |
||
matrix_get_backup_key( $user, '', '', 'bogusversion'); | ||
})->main::expect_http_404; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you use |
||
}; | ||
|
||
test "Can backup keys", | ||
requires => [ $fixture, qw( can_create_backup_version ) ], | ||
|
||
|
@@ -295,7 +331,13 @@ | |
version => $content->{version}, | ||
} | ||
); | ||
})->main::expect_http_404; | ||
})->then( sub { | ||
my ( $content ) = @_; | ||
|
||
assert_deeply_eq($content, {"rooms" => {}}, "Expected new backup to be empty"); | ||
|
||
Future->done(1); | ||
}); | ||
}; | ||
|
||
|
||
|
@@ -393,9 +435,19 @@ =head2 matrix_get_backup_key | |
sub matrix_get_backup_key { | ||
my ( $user, $room_id, $session_id, $version ) = @_; | ||
|
||
my $uri; | ||
|
||
if ($session_id) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. probably better to check for definedness rather than truthiness ( Also, spaces inside parens please. (I don't make the rules...) |
||
$uri = "/unstable/room_keys/keys/$room_id/$session_id"; | ||
} elsif ($room_id) { | ||
$uri = "/unstable/room_keys/keys/$room_id"; | ||
} else { | ||
$uri = "/unstable/room_keys/keys"; | ||
} | ||
|
||
do_request_json_for( $user, | ||
method => "GET", | ||
uri => "/unstable/room_keys/keys/$room_id/$session_id", | ||
uri => $uri, | ||
params => { | ||
version => $version, | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could we have a more descriptive description than "Content" ? (likewise below)