Skip to content

Commit 7fb11f0

Browse files
committed
Add integration test
1 parent c2a864a commit 7fb11f0

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

tests/graph.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
//! Integration tests for the `graph` command.
2+
use muse2::cli::{GraphOpts, handle_graph_command};
3+
use muse2::log::is_logger_initialised;
4+
use muse2::settings::Settings;
5+
use std::path::PathBuf;
6+
use tempfile::tempdir;
7+
8+
/// Get the path to the example model.
9+
fn get_model_dir() -> PathBuf {
10+
PathBuf::from("examples/simple")
11+
}
12+
13+
/// An integration test for the `graph` command.
14+
///
15+
/// We also check that the logger is initialised after it is run.
16+
#[test]
17+
fn test_handle_graph_command() {
18+
unsafe { std::env::set_var("MUSE2_LOG_LEVEL", "off") };
19+
20+
assert!(!is_logger_initialised());
21+
22+
// Save results to non-existent directory to check that directory creation works
23+
let tempdir = tempdir().unwrap();
24+
let output_dir = tempdir.path().join("results");
25+
let opts = GraphOpts {
26+
output_dir: Some(output_dir),
27+
overwrite: false,
28+
};
29+
handle_graph_command(&get_model_dir(), &opts, Some(Settings::default())).unwrap();
30+
31+
assert!(is_logger_initialised());
32+
}

0 commit comments

Comments
 (0)