mirror of
https://github.com/storytold/photocraft.git
synced 2026-12-03 06:31:42 +01:00
Check Cargo artifact freshness in fixture
This commit is contained in:
1 parent
fc17b2d5fa
commit
4dc260d9e8
1 file changed
+15
-9
@@ -132,15 +132,21 @@ mod tests {
|
||||
assert!(out.status.success(), "{}", String::from_utf8_lossy(&out.stderr));
|
||||
out
|
||||
};
|
||||
let first = list();
|
||||
assert!(String::from_utf8_lossy(&first.stderr).contains("Compiling"));
|
||||
let (mut record, mut listing) = (Vec::new(), Vec::new());
|
||||
route(first.stdout.as_slice(), &mut record, &mut listing).unwrap();
|
||||
assert!(String::from_utf8_lossy(&record).contains("compiler-artifact"));
|
||||
let json: serde_json::Value = serde_json::from_slice(&listing).unwrap();
|
||||
assert_eq!(json["rust-binaries"].as_object().unwrap().len(), 1);
|
||||
let second = list();
|
||||
assert!(!String::from_utf8_lossy(&second.stderr).contains("Compiling"));
|
||||
for expected_fresh in [false, true] {
|
||||
let output = list();
|
||||
let (mut record, mut listing) = (Vec::new(), Vec::new());
|
||||
route(output.stdout.as_slice(), &mut record, &mut listing).unwrap();
|
||||
let artifacts: Vec<serde_json::Value> = record
|
||||
.split(|&b| b == b'\n')
|
||||
.filter(|line| !line.is_empty())
|
||||
.map(|line| serde_json::from_slice(line).unwrap())
|
||||
.filter(|message: &serde_json::Value| message["reason"] == "compiler-artifact")
|
||||
.collect();
|
||||
assert!(!artifacts.is_empty());
|
||||
assert!(artifacts.iter().all(|message| message["fresh"].as_bool() == Some(expected_fresh)));
|
||||
let json: serde_json::Value = serde_json::from_slice(&listing).unwrap();
|
||||
assert_eq!(json["rust-binaries"].as_object().unwrap().len(), 1);
|
||||
}
|
||||
std::fs::remove_dir_all(dir).unwrap();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user