Skip to content

Commit

Permalink
test: add new test
Browse files Browse the repository at this point in the history
  • Loading branch information
Ebedthan committed Feb 6, 2024
1 parent 87a009a commit 3124ad2
Showing 1 changed file with 32 additions and 1 deletion.
33 changes: 32 additions & 1 deletion src/cmd/taxon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ pub struct TaxonSearchResult {
matches: Vec<String>,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
#[serde(transparent)]
pub struct TaxonGenomes {
data: Vec<String>,
Expand Down Expand Up @@ -411,4 +411,35 @@ mod tests {
assert!(file_contents.contains("g__Aminobacter"));
std::fs::remove_file("test_search.json").unwrap();
}

#[test]
fn test_get_genomes_with_output() -> Result<()> {
let args = TaxonArgs {
name: vec!["g__Escherichia".to_string()],
raw: true,
output: Some("output.json".to_string()),
partial: false,
search: false,
search_all: false,
genomes: true,
reps_only: false,
};

let actual_output = args.get_output().unwrap();

get_taxon_genomes(args)?;

let expected_output = fs::read_to_string("output.json")?;
let expected_taxon_data: TaxonGenomes = serde_json::from_str(&expected_output)?;

let actual_output = fs::read_to_string(actual_output)?;
let actual_taxon_data: TaxonGenomes = serde_json::from_str(&actual_output)?;

assert_eq!(expected_taxon_data, actual_taxon_data);

// Clean up the output file
fs::remove_file("output.json")?;

Ok(())
}
}

0 comments on commit 3124ad2

Please sign in to comment.