Skip to content

Commit

Permalink
Merge pull request #13 from timflannagan/ci/add-basic-bundle-test
Browse files Browse the repository at this point in the history
Add basic scratch-based container image tests
  • Loading branch information
timflannagan authored Jul 14, 2022
2 parents 13e5748 + 421d33c commit fb59ed3
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const PRG: &str = "dcp";
const TEST_CONTENT_DIR: &str = "/tmp/dcp_test_run";
const DEFAULT_IMAGE: &str = "quay.io/tyslaton/sample-catalog:v0.0.4";
const IMAGE_NO_TAG: &str = "quay.io/tyslaton/sample-catalog";
const SCRATCH_BASE_IMAGE: &str = "quay.io/tflannag/bundles:resolveset-v0.0.2";

// generate_temp_path takes the constant TEST_CONTENT_DIR and
// returns a new string with an appended 5 digit string
Expand Down Expand Up @@ -71,6 +72,24 @@ fn accepts_content_path() -> TestResult {
Ok(())
}

// --------------------------------------------------
#[test]
fn fails_invalid_content_path() -> TestResult {
let path = &generate_temp_path();
let content_path = "manifests";

// --content-path has been specified but fails as
// there's no "manifests" directory in the
// DEFAULT_IMAGE container image.
Command::cargo_bin(PRG)?
.args(&["--download-path", path])
.args(&["--content-path", content_path, DEFAULT_IMAGE])
.assert()
.failure();

Ok(())
}

// --------------------------------------------------
#[test]
fn accepts_image() -> TestResult {
Expand Down Expand Up @@ -121,3 +140,17 @@ fn fails_on_just_tag() -> TestResult {

Ok(())
}

// --------------------------------------------------
#[test]
fn accepts_scratch_base_images() -> TestResult {
let content_path: &str = "manifests";

Command::cargo_bin(PRG)?
.args(&["--content-path", content_path])
.args(&[SCRATCH_BASE_IMAGE])
.assert()
.success();

Ok(())
}

0 comments on commit fb59ed3

Please sign in to comment.