Skip to content

Commit

Permalink
Remove unexpected_error tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sr-gi committed Aug 24, 2022
1 parent dcbcee3 commit 3a822c3
Showing 1 changed file with 0 additions and 42 deletions.
42 changes: 0 additions & 42 deletions watchtower-plugin/src/net/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,36 +385,6 @@ mod tests {
assert!(matches!(error, AddAppointmentError::ApiError { .. }));
}

#[tokio::test]
async fn test_send_appointment_unexpected() {
// An example to trigger an unexpected error would be to try to send data to a wrongly formatted url.
// This can not happen in the codebase, since the url is tested on registration, but it can be used to
// test that error path. Generally speaking, that error path should be unreachable.
let wrong_tower_net_addr = "server_addr";

let server = MockServer::start();
server.mock(|when, then| {
when.method(POST).path("/add_appointment");
then.status(200).header("content-type", "application/json");
});

let error = send_appointment(
get_random_user_id(),
wrong_tower_net_addr,
None,
&generate_random_appointment(None),
"user_sig",
)
.await
.unwrap_err();

if let AddAppointmentError::RequestError(e) = error {
assert!(matches!(e, RequestError::Unexpected { .. }))
} else {
panic!("Funny enough, Unexpected error was expected")
}
}

#[tokio::test]
async fn test_post_request() {
let server = MockServer::start();
Expand Down Expand Up @@ -443,18 +413,6 @@ mod tests {
));
}

#[tokio::test]
async fn test_post_request_unexpected_error() {
let malformed_server_url = "server_addr";

assert!(matches!(
post_request(malformed_server_url, json!(""), None,)
.await
.unwrap_err(),
RequestError::Unexpected { .. }
));
}

#[tokio::test]
async fn test_process_post_response_json_error() {
// `process_post_response` is a pass-trough function that maps json deserialization errors from `post_request`.
Expand Down

0 comments on commit 3a822c3

Please sign in to comment.