Skip to content

Commit

Permalink
tests: Fix tests calling nonexistent or old binary build (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
rkarp authored Jul 7, 2024
1 parent 377ff2b commit 148a83b
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 61 deletions.
61 changes: 0 additions & 61 deletions src/cli/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ pub struct Input {

#[cfg(test)]
mod tests {
use assert_cmd::Command;
use clap::ValueEnum;
use secrecy::Secret;

Expand Down Expand Up @@ -180,64 +179,4 @@ mod tests {
assert!(Account::try_from_str("").is_err());
assert!(Account::try_from_str(" ").is_err());
}

#[test]
fn parse_input() {
let args_permutations = vec![
vec![
"--account=user",
"--token=ghs_sSIL4kMdtzfbfDdm1MC1OU2q5DbRqA3eSszT",
"--image-names=foo",
"--image-tags=one",
"--shas-to-skip=",
"--keep-n-most-recent=0",
"--tag-selection=tagged",
"--timestamp-to-use=updated_at",
"--cut-off=1w",
"--dry-run=true",
],
vec![
"--account=acme",
"--token=ghp_sSIL4kMdtzfbfDdm1MC1OU2q5DbRqA3eSszT",
"--image-names=\"foo bar\"",
"--image-tags=\"one two\"",
"--shas-to-skip=",
"--keep-n-most-recent=10",
"--tag-selection=untagged",
"--timestamp-to-use=created_at",
"--cut-off=1d",
"--dry-run=true",
],
vec![
"--account=foo",
"--token=ghp_sSIL4kMdtzfbfDdm1MC1OU2q5DbRqA3eSszT",
"--image-names=\"foo, bar\"",
"--image-tags=\"one, two\"",
"--shas-to-skip=''",
"--keep-n-most-recent=999",
"--tag-selection=both",
"--timestamp-to-use=updated_at",
"--cut-off=1h",
"--dry-run=true",
],
vec![
"--account=$;\u{b}\n₭↭",
"--token=ghp_sSIL4kMdtzfbfDdm1MC1OU2q5DbRqA3eSszT",
"--image-names=\"foo, bar\"",
"--image-tags=\"one, two\"",
"--shas-to-skip=''",
"--keep-n-most-recent=2",
"--tag-selection=both",
"--timestamp-to-use=updated_at",
"--cut-off=1h",
"--dry-run=true",
],
];

for args in args_permutations {
let mut cmd = Command::cargo_bin("container-retention-policy").expect("Failed to load binary");

cmd.env("CRP_TEST", "true").args(args).assert().success();
}
}
}
61 changes: 61 additions & 0 deletions tests/integration_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
use assert_cmd::Command;

#[test]
fn parse_input() {
let args_permutations = vec![
vec![
"--account=user",
"--token=ghs_sSIL4kMdtzfbfDdm1MC1OU2q5DbRqA3eSszT",
"--image-names=foo",
"--image-tags=one",
"--shas-to-skip=",
"--keep-n-most-recent=0",
"--tag-selection=tagged",
"--timestamp-to-use=updated_at",
"--cut-off=1w",
"--dry-run=true",
],
vec![
"--account=acme",
"--token=ghp_sSIL4kMdtzfbfDdm1MC1OU2q5DbRqA3eSszT",
"--image-names=\"foo bar\"",
"--image-tags=\"one two\"",
"--shas-to-skip=",
"--keep-n-most-recent=10",
"--tag-selection=untagged",
"--timestamp-to-use=created_at",
"--cut-off=1d",
"--dry-run=true",
],
vec![
"--account=foo",
"--token=ghp_sSIL4kMdtzfbfDdm1MC1OU2q5DbRqA3eSszT",
"--image-names=\"foo, bar\"",
"--image-tags=\"one, two\"",
"--shas-to-skip=''",
"--keep-n-most-recent=999",
"--tag-selection=both",
"--timestamp-to-use=updated_at",
"--cut-off=1h",
"--dry-run=true",
],
vec![
"--account=$;\u{b}\n₭↭",
"--token=ghp_sSIL4kMdtzfbfDdm1MC1OU2q5DbRqA3eSszT",
"--image-names=\"foo, bar\"",
"--image-tags=\"one, two\"",
"--shas-to-skip=''",
"--keep-n-most-recent=2",
"--tag-selection=both",
"--timestamp-to-use=updated_at",
"--cut-off=1h",
"--dry-run=true",
],
];

for args in args_permutations {
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).expect("Failed to load binary");

cmd.env("CRP_TEST", "true").args(args).assert().success();
}
}

0 comments on commit 148a83b

Please sign in to comment.