libcnb-test
An experimental integration testing framework for Cloud Native Buildpacks written in Rust with libcnb.rs.
Experimental
This crate is marked as experimental. It currently implements the most basic building blocks for writing
integration tests with libcnb.rs. Its feature set is deliberately cut down to get ball rolling and get a better feel
which features are required. See issues tagged with libcnb-test for possible future improvements.
Please use the same tag for feature requests.
Example
use libcnb_test::{IntegrationTest, BuildpackReference, assert_contains};
#[test]
fn test() {
IntegrationTest::new("heroku/buildpacks:20", "test-fixtures/app")
.buildpacks(vec![
BuildpackReference::Other(String::from("heroku/openjdk")),
BuildpackReference::Crate,
])
.run_test(|context| {
assert_contains!(context.pack_stdout, "---> Maven Buildpack");
assert_contains!(context.pack_stdout, "---> Installing Maven");
assert_contains!(context.pack_stdout, "---> Running mvn package");
context.start_container(&[12345], |container| {
assert_eq!(
call_test_fixture_service(
container.address_for_port(12345).unwrap(),
"Hagbard Celine"
)
.unwrap(),
"enileC drabgaH"
);
});
});
}
fn call_test_fixture_service(addr: std::net::SocketAddr, payload: &str) -> Result<String, ()> {
unimplemented!()
}