pub struct TestConfig { /* private fields */ }
Expand description

Configuration for a test.

Implementations

Creates a new test configuration.

If the app_dir parameter is a relative path, it is treated as relative to the Cargo manifest directory (CARGO_MANIFEST_DIR), i.e. the package’s root directory.

Sets the buildpacks order.

Defaults to BuildpackReference::Crate.

Sets the target triple used when compiling the buildpack.

Defaults to x86_64-unknown-linux-musl.

Inserts or updates an environment variable mapping for the build process.

Note: This does not set this environment variable for running containers, it’s only available during the build.

Example
use libcnb_test::{TestConfig, TestRunner};

TestRunner::default().run_test(
    TestConfig::new("heroku/builder:22", "test-fixtures/app")
        .env("ENV_VAR_ONE", "VALUE ONE")
        .env("ENV_VAR_TWO", "SOME OTHER VALUE"),
    |context| {
        // ...
    },
)

Adds or updates multiple environment variable mappings for the build process.

Note: This does not set environment variables for running containers, they’re only available during the build.

Example
use libcnb_test::{TestConfig, TestRunner};

TestRunner::default().run_test(
    TestConfig::new("heroku/builder:22", "test-fixtures/app").envs(vec![
        ("ENV_VAR_ONE", "VALUE ONE"),
        ("ENV_VAR_TWO", "SOME OTHER VALUE"),
    ]),
    |context| {
        // ...
    },
);

Sets an app directory preprocessor function.

It will be run after the app directory has been copied for the current integration test run, the changes will not affect other integration test runs.

Generally, we suggest using dedicated test fixtures. However, in some cases it is more economical to slightly modify a fixture programmatically before a test instead.

Example
use libcnb_test::{TestConfig, TestRunner};

TestRunner::default().run_test(
    TestConfig::new("heroku/builder:22", "test-fixtures/app").app_dir_preprocessor(
        |app_dir| std::fs::remove_file(app_dir.join("Procfile")).unwrap(),
    ),
    |context| {
        // ...
    },
);

Sets the app directory.

The app directory is normally set in the TestConfig::new call, but when sharing test configuration, it might be necessary to change the app directory but keep everything else the same.

Set the expected pack command result.

In some cases, users might want to explicitly test that a build fails and asserting against error output. When passed PackResult::Failure, the test will fail if the pack build succeeds and vice-versa.

Defaults to PackResult::Success

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more