mirror of
https://gitlab.cern.ch/wotsubo/psboard-qaqc-postprocess.git
synced 2024-11-22 07:10:18 +09:00
78 lines
2.2 KiB
Rust
78 lines
2.2 KiB
Rust
mod integrated_test {
|
|
use std::{
|
|
fs::File,
|
|
io::{BufRead, BufReader},
|
|
path::PathBuf,
|
|
};
|
|
|
|
use anyhow::Result;
|
|
use assert_cmd::Command;
|
|
use predicates::prelude::*;
|
|
|
|
#[test]
|
|
fn full_log() -> Result<()> {
|
|
let test_out_dir = assert_fs::TempDir::new()?;
|
|
let test_out = PathBuf::new().join(&test_out_dir).join("out.csv");
|
|
|
|
// 1st file
|
|
let mut cmd = Command::cargo_bin("psb-qaqc")?;
|
|
cmd.current_dir("tests")
|
|
.arg("add-master-log")
|
|
.arg("./example_logs/valid/20240720_171418.log")
|
|
.arg(test_out.as_path())
|
|
.assert()
|
|
.success()
|
|
.stdout(predicate::str::contains("Creating new file"));
|
|
|
|
// check output
|
|
{
|
|
let f = File::open(test_out.clone())?;
|
|
let r = BufReader::new(f);
|
|
assert!(r
|
|
.lines()
|
|
.any(|line| {
|
|
line
|
|
.unwrap()
|
|
.contains(
|
|
"8866,,A-0-0,0,1,1,0,1,8,1,,2024-07-20T17:15:46Z,20240720_171418.log,0.1.0,alice,,,,"
|
|
)
|
|
}));
|
|
}
|
|
|
|
// 2nd file
|
|
let mut cmd = Command::cargo_bin("psb-qaqc")?;
|
|
cmd.current_dir("tests")
|
|
.arg("add-master-log")
|
|
.arg("./example_logs/valid/20240720_171418.log")
|
|
.arg(test_out.as_path())
|
|
.assert()
|
|
.success();
|
|
|
|
// check
|
|
let mut cmd = Command::cargo_bin("psb-qaqc")?;
|
|
cmd.current_dir("tests")
|
|
.arg("check-db")
|
|
.arg(test_out.as_path())
|
|
.assert()
|
|
.success();
|
|
|
|
Ok(())
|
|
}
|
|
|
|
#[test]
|
|
fn partial_log() -> Result<()> {
|
|
let test_out_dir = assert_fs::TempDir::new()?;
|
|
let test_out = PathBuf::new().join(&test_out_dir).join("out.csv");
|
|
|
|
let mut cmd = Command::cargo_bin("psb-qaqc")?;
|
|
cmd.current_dir("tests")
|
|
.arg("add-master-log")
|
|
.arg("./example_logs/valid/20240720_171419.log")
|
|
.arg(test_out.as_path())
|
|
.assert()
|
|
.success()
|
|
.stdout(predicate::str::contains("Creating new file"));
|
|
|
|
Ok(())
|
|
}
|
|
}
|