Skip to content

Commit

Permalink
add header filter tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ghubertpalo committed Dec 13, 2022
1 parent d74bca1 commit dd0fb88
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions mithril-aggregator/src/http_server/routes/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,40 @@ pub async fn handle_custom(reject: Rejection) -> Result<impl Reply, Rejection> {
Err(reject)
}
}

#[cfg(test)]
mod tests {
use super::*;

#[tokio::test]
async fn test_no_version() {
let filters = header_must_be();
warp::test::request()
.path("/aggregator/whatever")
.filter(&filters)
.await
.unwrap();
}

#[tokio::test]
async fn test_bad_version() {
let filters = header_must_be();
warp::test::request()
.header("mithril-api-version", "0.0.999")
.path("/aggregator/whatever")
.filter(&filters)
.await
.unwrap_err();
}

#[tokio::test]
async fn test_good_version() {
let filters = header_must_be();
warp::test::request()
.header("mithril-api-version", MITHRIL_API_VERSION)
.path("/aggregator/whatever")
.filter(&filters)
.await
.unwrap();
}
}

0 comments on commit dd0fb88

Please sign in to comment.