Skip to content

Commit

Permalink
fixed app tests
Browse files Browse the repository at this point in the history
  • Loading branch information
esteinig committed Feb 18, 2023
1 parent 69898fa commit 3dfe52f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 41 deletions.
4 changes: 2 additions & 2 deletions src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ pub struct Cli {
/// Output the coverage statistics as a pretty table; may still get
/// mangled on short terminals, as terminal width cannot currently
/// be estimated in underlying library.
#[structopt(short = "t", long = "table")]
#[structopt(short = "T", long = "table")]
pub table: bool,
/// Prints coverage plots
///
Expand Down Expand Up @@ -149,7 +149,7 @@ pub struct Cli {
/// with fewer distinct alignment regions to pass the basic filter. For example,
/// a reference sequence with 100% coverage and 1 distinct alignment regions would
/// not be filtered from the report output.
#[structopt(short = "r", long = "regions-coverage")]
#[structopt(short = "t", long = "regions-coverage")]
pub regions_coverage: Option<f64>,
/// Minimum read threshold (unique reads in alignment)
///
Expand Down
55 changes: 16 additions & 39 deletions tests/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use std::process::Command;
#[test]
fn input_file_doesnt_exist() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))?;
cmd.args(vec!["--paf", "file/doesnt/exist.paf"]);
cmd.args(vec!["--alignment", "file/doesnt/exist.paf"]);
cmd.assert()
.failure()
.stderr(predicate::str::contains("does not exist"));
Expand All @@ -17,7 +17,7 @@ fn input_file_doesnt_exist() -> Result<(), Box<dyn std::error::Error>> {
fn valid_inputs_raise_no_errors() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))?;
cmd.args(vec![
"--paf",
"--alignment",
"tests/cases/test_ok.paf",
"--fasta",
"tests/cases/test_paf_ok.fasta",
Expand All @@ -33,37 +33,14 @@ fn valid_inputs_raise_no_errors() -> Result<(), Box<dyn std::error::Error>> {
fn valid_output_string_default_filters() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))?;
cmd.args(vec![
"--paf",
"--alignment",
"tests/cases/test_ok.paf",
"--fasta",
"tests/cases/test_paf_ok.fasta",
]);

cmd.assert().success().stdout(predicate::str::contains(
"21172389_LCMV_L-segment_final\t2\t1\t2\t273\t7194\t0.0379\t",
));

Ok(())
}

#[test]
fn valid_output_string_no_filters() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))?;
cmd.args(vec![
"--paf",
"tests/cases/test_ok.paf",
"--fasta",
"tests/cases/test_paf_ok.fasta",
"--min-mapq",
"0",
"--min-len",
"0",
"--min-cov",
"0",
]);

cmd.assert().success().stdout(predicate::str::contains(
"21172389_LCMV_L-segment_final\t3\t2\t3\t321\t7194\t0.0446\t-\t-\n21172389_LCMV_S-segment_final\t2\t2\t2\t137\t3407\t0.0402\t-\t-"
"21172389_LCMV_L-segment_final\t3\t2\t3\t321\t7194\t0.0446\t-\t-\n21172389_LCMV_S-segment_final\t2\t2\t2\t137\t3407\t0.0402\t-\t-\n"
));

Ok(())
Expand All @@ -74,15 +51,15 @@ fn valid_output_string_default_filters_verbose_one_no_descr(
) -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))?;
cmd.args(vec![
"--paf",
"--alignment",
"tests/cases/test_ok.paf",
"--fasta",
"tests/cases/test_paf_ok.fasta",
"-v",
]);

cmd.assert().success().stdout(predicate::str::contains(
"21172389_LCMV_L-segment_final\t2\t1\t2\t273\t7194\t0.0379\t-\t-",
"21172389_LCMV_L-segment_final\t3\t2\t3\t321\t7194\t0.0446\t-\t-",
));

Ok(())
Expand All @@ -93,16 +70,16 @@ fn valid_output_string_default_filters_region_threshold_pass(
) -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))?;
cmd.args(vec![
"--paf",
"--alignment",
"tests/cases/test_ok.paf",
"--fasta",
"tests/cases/test_paf_ok.fasta",
"-r",
"--regions",
"2",
]);

cmd.assert().success().stdout(predicate::str::contains(
"21172389_LCMV_L-segment_final\t2\t1\t2\t273\t7194\t0.0379\t",
"21172389_LCMV_L-segment_final\t3\t2\t3\t321\t7194\t0.0446\t-\t-",
));

Ok(())
Expand All @@ -113,11 +90,11 @@ fn valid_output_string_default_filters_region_threshold_none(
) -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))?;
cmd.args(vec![
"--paf",
"--alignment",
"tests/cases/test_ok.paf",
"--fasta",
"tests/cases/test_paf_ok.fasta",
"-r",
"--regions",
"3",
]);

Expand All @@ -131,16 +108,16 @@ fn valid_output_string_default_filters_refseq_length_pass() -> Result<(), Box<dy
{
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))?;
cmd.args(vec![
"--paf",
"--alignment",
"tests/cases/test_ok.paf",
"--fasta",
"tests/cases/test_paf_ok.fasta",
"-s",
"--length",
"5000",
]);

cmd.assert().success().stdout(predicate::str::contains(
"21172389_LCMV_L-segment_final\t2\t1\t2\t273\t7194\t0.0379\t",
"21172389_LCMV_L-segment_final\t3\t2\t3\t321\t7194\t0.0446\t-\t-",
));

Ok(())
Expand All @@ -151,11 +128,11 @@ fn valid_output_string_default_filters_refseq_length_none() -> Result<(), Box<dy
{
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME"))?;
cmd.args(vec![
"--paf",
"--alignment",
"tests/cases/test_ok.paf",
"--fasta",
"tests/cases/test_paf_ok.fasta",
"-s",
"--length",
"8000",
]);

Expand Down

0 comments on commit 3dfe52f

Please sign in to comment.