Crates.io | charted-testkit |
lib.rs | charted-testkit |
version | 0.1.2 |
source | src |
created_at | 2024-06-23 22:15:53.055032 |
updated_at | 2024-12-08 04:31:02.496145 |
description | 📦🦋 TestKit is a testing library for Axum services with testcontainers support |
homepage | |
repository | |
max_upload_size | |
id | 1281468 |
size | 74,037 |
charted TestKit is a testing library for Axum, which extends libtest
with its own test
macro. The library can also be used for only Testcontainers as well.
TestKit was built to make integration testing easier for Axum services with Testcontainers support and additional macros to help build assertions based off Response
s.
use charted_testkit::{test, TestContext, assert_successful, consume_body};
use axum::{body::Bytes, routing, Router};
use hyper::Method;
async fn hello() -> &'static str {
"Hello, world!"
}
fn router() -> Router {
Router::new().route("/", routing::get(hello))
}
#[test(router)]
async fn mytest(ctx: TestContext) {
let res = ctx
.request("/", Method::GET, None::<axum::body::Bytes>, |_| {})
.await
.expect("unable to send request");
assert_successful!(res);
let body = consume_body!(res);
assert_eq!(body, Bytes::from_static(b"Hello, world!"));
}
TestKit is released under the MIT
License with love and care by Noelware, LLC.! 🐻❄️🦋
Please read the LICENSE
file in the canonical repository for more information on what you can do with the source code.