Skip to content

Commit 9390815

Browse files
jyn514Joshua Nelson
authored and
Joshua Nelson
committed
make it clearer what assert_redirect() is doing
1 parent 2d4a40d commit 9390815

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/test/mod.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,20 +39,23 @@ pub(crate) fn assert_success(path: &str, web: &TestFrontend) -> Result<(), Error
3939

4040
/// Make sure that a URL redirects to a specific page
4141
pub(crate) fn assert_redirect(path: &str, expected_target: &str, web: &TestFrontend) -> Result<(), Error> {
42+
// Reqwest follows redirects automatically
4243
let response = web.get(path).send()?;
4344
let status = response.status();
4445

45-
// Reqwest follows redirects automatically
4646
let redirect_target = if expected_target.starts_with("https://") {
4747
response.url().as_str()
4848
} else {
4949
response.url().path()
5050
};
51+
// Either we followed a redirect to the wrong place, or there was no redirect
5152
if redirect_target != expected_target {
53+
// wrong place
5254
if redirect_target != path {
5355
panic!("{}: expected redirect to {}, got redirect to {}",
5456
path, expected_target, redirect_target);
5557
} else {
58+
// no redirect
5659
panic!("{}: expected redirect to {}, got {}", path, expected_target, status);
5760
}
5861
}

0 commit comments

Comments
 (0)