Struct libcnb_test::TestRunner
source · pub struct TestRunner {}
Expand description
Runner for libcnb integration tests.
§Example
use libcnb_test::{assert_contains, assert_empty, BuildConfig, TestRunner};
TestRunner::default().build(
BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
|context| {
assert_empty!(context.pack_stderr);
assert_contains!(context.pack_stdout, "Expected build output");
},
)
Implementations§
source§impl TestRunner
impl TestRunner
sourcepub fn build<C: Borrow<BuildConfig>, F: FnOnce(TestContext<'_>)>(
&self,
config: C,
f: F
)
pub fn build<C: Borrow<BuildConfig>, F: FnOnce(TestContext<'_>)>( &self, config: C, f: F )
Starts a new integration test build.
This function copies the application to a temporary directory (if necessary), cross-compiles the current
crate, packages it as a buildpack and then invokes pack
to build a new Docker image with the buildpacks specified by the passed BuildConfig
.
After the passed test function has returned, the Docker image and volumes created by Pack are removed.
Since this function is supposed to only be used in integration tests, failures are not
signalled via Result
values. Instead, this function panics whenever an unexpected error
occurred to simplify testing code.
§Example
use libcnb_test::{assert_contains, assert_empty, BuildConfig, TestRunner};
TestRunner::default().build(
BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
|context| {
assert_empty!(context.pack_stderr);
assert_contains!(context.pack_stdout, "Expected build output");
},
)
Trait Implementations§
source§impl Default for TestRunner
impl Default for TestRunner
source§fn default() -> TestRunner
fn default() -> TestRunner
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TestRunner
impl RefUnwindSafe for TestRunner
impl Send for TestRunner
impl Sync for TestRunner
impl Unpin for TestRunner
impl UnwindSafe for TestRunner
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more