Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use a consistent approach for organising test fixture files #681

Merged
merged 1 commit into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/target/
/packaged/
target/
edmorley marked this conversation as resolved.
Show resolved Hide resolved
.DS_Store
.idea

# Since libcnb.rs is a library, we don't commit the lockfile so that CI tests the latest
# in-range dependencies, which is what users will use when installing from scratch.
Cargo.lock
**/fixtures/*/target/
**/fixtures/*/packaged/
**/test-fixtures/buildpacks/*/target/

# The default output directory of `cargo libcnb package`.
packaged/
2 changes: 1 addition & 1 deletion examples/execd/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use libcnb_test::{assert_contains, assert_empty, BuildConfig, TestRunner};
#[ignore = "integration test"]
fn basic() {
TestRunner::default().build(
BuildConfig::new("heroku/builder:22", "test-fixtures/empty-app"),
BuildConfig::new("heroku/builder:22", "tests/fixtures/empty-app"),
|context| {
let command_output = context.run_shell_command("env");
assert_empty!(command_output.stderr);
Expand Down
4 changes: 2 additions & 2 deletions examples/ruby-sample/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use std::{fs, io};
#[test]
#[ignore = "integration test"]
fn basic() {
let config = BuildConfig::new("heroku/buildpacks:20", "test-fixtures/simple-ruby-app");
let config = BuildConfig::new("heroku/buildpacks:20", "tests/fixtures/simple-ruby-app");

TestRunner::default().build(&config, |context| {
assert_contains!(context.pack_stdout, "---> Ruby Buildpack");
Expand Down Expand Up @@ -60,7 +60,7 @@ fn basic() {
#[ignore = "integration test"]
fn missing_gemfile_lock() {
TestRunner::default().build(
BuildConfig::new("heroku/buildpacks:20", "test-fixtures/simple-ruby-app")
BuildConfig::new("heroku/buildpacks:20", "tests/fixtures/simple-ruby-app")
.app_dir_preprocessor(|path| fs::remove_file(path.join("Gemfile.lock")).unwrap())
.expected_pack_result(PackResult::Failure),
|context| {
Expand Down
2 changes: 1 addition & 1 deletion libcnb-cargo/tests/integration_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ fn validate_packaged_meta_buildpack(

fn copy_fixture_to_temp_dir(name: &str) -> Result<TempDir, std::io::Error> {
let fixture_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR"))
.join("fixtures")
.join("tests/fixtures")
.join(name);

// Instead of using `tempfile::tempdir` directly, we get the temporary directory ourselves and
Expand Down
16 changes: 8 additions & 8 deletions libcnb-test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ use libcnb_test::{assert_contains, assert_empty, BuildConfig, TestRunner};
// #[test]
fn basic() {
TestRunner::default().build(
BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
|context| {
assert_empty!(context.pack_stderr);
assert_contains!(context.pack_stdout, "Expected build output");
Expand All @@ -54,7 +54,7 @@ use libcnb_test::{assert_contains, BuildConfig, TestRunner};
// #[test]
fn rebuild() {
TestRunner::default().build(
BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
|context| {
assert_contains!(context.pack_stdout, "Installing dependencies");

Expand All @@ -75,7 +75,7 @@ use libcnb_test::{assert_contains, BuildConfig, PackResult, TestRunner};
// #[test]
fn expected_pack_failure() {
TestRunner::default().build(
BuildConfig::new("heroku/builder:22", "test-fixtures/invalid-app")
BuildConfig::new("heroku/builder:22", "tests/fixtures/invalid-app")
.expected_pack_result(PackResult::Failure),
|context| {
assert_contains!(context.pack_stderr, "ERROR: Invalid Procfile!");
Expand All @@ -92,7 +92,7 @@ use libcnb_test::{assert_empty, BuildConfig, TestRunner};
// #[test]
fn run_shell_command() {
TestRunner::default().build(
BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
|context| {
// ...
let command_output = context.run_shell_command("python --version");
Expand All @@ -115,7 +115,7 @@ const TEST_PORT: u16 = 12345;
// #[test]
fn starting_web_server_container() {
TestRunner::default().build(
BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
|context| {
// ...
context.start_container(
Expand Down Expand Up @@ -154,7 +154,7 @@ use libcnb_test::{assert_contains, BuildConfig, ContainerConfig, TestRunner};
// #[test]
fn shell_exec() {
TestRunner::default().build(
BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
|context| {
// ...
context.start_container(ContainerConfig::new(), |container| {
Expand All @@ -176,7 +176,7 @@ use std::fs;
// #[test]
fn dynamic_fixture() {
TestRunner::default().build(
BuildConfig::new("heroku/builder:22", "test-fixtures/app").app_dir_preprocessor(
BuildConfig::new("heroku/builder:22", "tests/fixtures/app").app_dir_preprocessor(
|app_dir| {
fs::write(app_dir.join("runtime.txt"), "python-3.10").unwrap();
},
Expand All @@ -197,7 +197,7 @@ use libcnb_test::{BuildConfig, BuildpackReference, TestRunner};
// #[test]
fn additional_buildpacks() {
TestRunner::default().build(
BuildConfig::new("heroku/builder:22", "test-fixtures/app").buildpacks([
BuildConfig::new("heroku/builder:22", "tests/fixtures/app").buildpacks([
BuildpackReference::CurrentCrate,
BuildpackReference::WorkspaceBuildpack(buildpack_id!("my-project/buildpack")),
BuildpackReference::Other(String::from("heroku/another-buildpack")),
Expand Down
20 changes: 10 additions & 10 deletions libcnb-test/src/build_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl BuildConfig {
/// use libcnb_test::{BuildConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // ...
/// },
Expand Down Expand Up @@ -59,7 +59,7 @@ impl BuildConfig {
/// use libcnb_test::{BuildConfig, BuildpackReference, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app").buildpacks([
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app").buildpacks([
/// BuildpackReference::CurrentCrate,
/// BuildpackReference::WorkspaceBuildpack(buildpack_id!("my-project/buildpack")),
/// BuildpackReference::Other(String::from("heroku/another-buildpack")),
Expand All @@ -83,7 +83,7 @@ impl BuildConfig {
/// use libcnb_test::{BuildConfig, CargoProfile, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app")
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app")
/// .cargo_profile(CargoProfile::Release),
/// |context| {
/// // ...
Expand All @@ -104,7 +104,7 @@ impl BuildConfig {
/// use libcnb_test::{BuildConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app")
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app")
/// .target_triple("x86_64-unknown-linux-musl"),
/// |context| {
/// // ...
Expand All @@ -126,7 +126,7 @@ impl BuildConfig {
/// use libcnb_test::{BuildConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app")
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app")
/// .env("ENV_VAR_ONE", "VALUE ONE")
/// .env("ENV_VAR_TWO", "SOME OTHER VALUE"),
/// |context| {
Expand All @@ -149,7 +149,7 @@ impl BuildConfig {
/// use libcnb_test::{BuildConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app").envs([
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app").envs([
/// ("ENV_VAR_ONE", "VALUE ONE"),
/// ("ENV_VAR_TWO", "SOME OTHER VALUE"),
/// ]),
Expand Down Expand Up @@ -182,7 +182,7 @@ impl BuildConfig {
/// use libcnb_test::{BuildConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app").app_dir_preprocessor(
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app").app_dir_preprocessor(
/// |app_dir| {
/// std::fs::remove_file(app_dir.join("Procfile")).unwrap();
/// },
Expand All @@ -208,11 +208,11 @@ impl BuildConfig {
/// use libcnb_test::{BuildConfig, TestRunner};
///
/// fn default_config() -> BuildConfig {
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app")
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app")
/// }
///
/// TestRunner::default().build(
/// default_config().app_dir("test-fixtures/a-different-app"),
/// default_config().app_dir("tests/fixtures/a-different-app"),
/// |context| {
/// // ...
/// },
Expand All @@ -236,7 +236,7 @@ impl BuildConfig {
/// use libcnb_test::{assert_contains, BuildConfig, PackResult, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app")
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app")
/// .expected_pack_result(PackResult::Failure),
/// |context| {
/// assert_contains!(context.pack_stderr, "ERROR: Invalid Procfile!");
Expand Down
14 changes: 7 additions & 7 deletions libcnb-test/src/container_config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use std::collections::{HashMap, HashSet};
/// use libcnb_test::{BuildConfig, ContainerConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // ...
/// context.start_container(
Expand Down Expand Up @@ -45,7 +45,7 @@ impl ContainerConfig {
/// use libcnb_test::{BuildConfig, ContainerConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // ...
/// context.start_container(
Expand Down Expand Up @@ -73,7 +73,7 @@ impl ContainerConfig {
/// use libcnb_test::{BuildConfig, ContainerConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // ...
/// context.start_container(ContainerConfig::new().entrypoint("worker"), |container| {
Expand All @@ -96,7 +96,7 @@ impl ContainerConfig {
/// use libcnb_test::{BuildConfig, ContainerConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // ...
/// context.start_container(
Expand All @@ -123,7 +123,7 @@ impl ContainerConfig {
/// use libcnb_test::{BuildConfig, ContainerConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // ...
/// context.start_container(
Expand All @@ -150,7 +150,7 @@ impl ContainerConfig {
/// use libcnb_test::{BuildConfig, ContainerConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // ...
/// context.start_container(
Expand All @@ -176,7 +176,7 @@ impl ContainerConfig {
/// use libcnb_test::{BuildConfig, ContainerConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // ...
/// context.start_container(
Expand Down
8 changes: 4 additions & 4 deletions libcnb-test/src/container_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ impl ContainerContext {
/// use libcnb_test::{assert_contains, assert_empty, BuildConfig, ContainerConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // ...
/// context.start_container(ContainerConfig::new(), |container| {
Expand Down Expand Up @@ -61,7 +61,7 @@ impl ContainerContext {
/// use libcnb_test::{assert_contains, assert_empty, BuildConfig, ContainerConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // ...
/// context.start_container(ContainerConfig::new(), |container| {
Expand Down Expand Up @@ -91,7 +91,7 @@ impl ContainerContext {
/// use libcnb_test::{BuildConfig, ContainerConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // ...
/// context.start_container(
Expand Down Expand Up @@ -146,7 +146,7 @@ impl ContainerContext {
/// use libcnb_test::{assert_contains, BuildConfig, ContainerConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // ...
/// context.start_container(ContainerConfig::new(), |container| {
Expand Down
10 changes: 5 additions & 5 deletions libcnb-test/src/test_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ impl<'a> TestContext<'a> {
/// use libcnb_test::{BuildConfig, ContainerConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // Start the container using the default process-type:
/// // https://buildpacks.io/docs/app-developer-guide/run-an-app/#default-process-type
Expand Down Expand Up @@ -126,7 +126,7 @@ impl<'a> TestContext<'a> {
/// use libcnb_test::{BuildConfig, ContainerConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // ...
/// let command_output =
Expand All @@ -141,7 +141,7 @@ impl<'a> TestContext<'a> {
/// use libcnb_test::{BuildConfig, ContainerConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// // ...
/// context.start_container(
Expand Down Expand Up @@ -203,7 +203,7 @@ impl<'a> TestContext<'a> {
/// use libcnb_test::{BuildConfig, ContainerConfig, SbomType, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// context.download_sbom_files(|sbom_files| {
/// assert!(sbom_files
Expand Down Expand Up @@ -254,7 +254,7 @@ impl<'a> TestContext<'a> {
/// use libcnb_test::{assert_contains, BuildConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// assert_contains!(context.pack_stdout, "---> Installing dependencies");
///
Expand Down
4 changes: 2 additions & 2 deletions libcnb-test/src/test_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use tempfile::tempdir;
/// use libcnb_test::{assert_contains, assert_empty, BuildConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// assert_empty!(context.pack_stderr);
/// assert_contains!(context.pack_stdout, "Expected build output");
Expand All @@ -40,7 +40,7 @@ impl TestRunner {
/// use libcnb_test::{assert_contains, assert_empty, BuildConfig, TestRunner};
///
/// TestRunner::default().build(
/// BuildConfig::new("heroku/builder:22", "test-fixtures/app"),
/// BuildConfig::new("heroku/builder:22", "tests/fixtures/app"),
/// |context| {
/// assert_empty!(context.pack_stderr);
/// assert_contains!(context.pack_stdout, "Expected build output");
Expand Down
Loading