mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-19 00:27:49 +00:00
Wait for style layers to clear, and cover a full asset-peak cap
inserts_and_detaches_count_per_style_and_variable_in_the_period returned as soon as detachments reached 2, then asserted layers == 0. Asset-action reports can arrive before the usage snapshot, so CI saw layers still at 1. The wait now requires both. Sonar on the same-repo vehicle (#2451) evaluated the coverage gate at 79.74% of 232 new lines (one line under 80%). A unit test covers grow's branch that drops a new key once peaks are already at MAX_REPORTED. Signed-off-by: FredApps <153173854+FredApps@users.noreply.github.com>
This commit is contained in:
1 parent
9e45db6885
commit
23e5877e6b
2 files changed
+15
-1
No files matched your search
@@ -183,7 +183,7 @@ fn inserts_and_detaches_count_per_style_and_variable_in_the_period() {
|
||||
ex(&mut b, "edit.undo", json!({}));
|
||||
ex(&mut b, "edit.redo", json!({}));
|
||||
ex(&mut b, "style.detach", json!({"ids": [one.0], "which": "fill"}));
|
||||
let u = usage_when(&mut a, &mut b, |u| u["styles"][0]["detachments"] == 2);
|
||||
let u = usage_when(&mut a, &mut b, |u| u["styles"][0]["detachments"] == 2 && u["styles"][0]["layers"] == 0);
|
||||
assert_eq!((u["styles"][0]["insertions"].clone(), u["styles"][0]["layers"].clone()), (json!(2), json!(0)), "{u}");
|
||||
assert_eq!(u["variables"][0]["insertions"], 1, "{u}");
|
||||
server.stop();
|
||||
|
||||
@@ -390,3 +390,17 @@ fn library_file(dir: &Path, version: u64) -> PathBuf {
|
||||
let path = dir.join(library_name(version));
|
||||
if path.exists() { path } else { dir.join(LIBRARY) }
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod grow_tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn a_new_key_is_dropped_once_peaks_are_full() {
|
||||
let mut peaks: Vec<(u32, u32, u32)> = (0..MAX_REPORTED as u32).map(|i| (i, 1, 0)).collect();
|
||||
let grown = grow(&mut peaks, &[(MAX_REPORTED as u32, 3)], Count::Inserted, |_| 0);
|
||||
assert!(grown.is_empty(), "a key past the cap must not start a peak or count as growth");
|
||||
assert_eq!(peaks.len(), MAX_REPORTED);
|
||||
assert!(peaks.iter().all(|p| p.0 < MAX_REPORTED as u32));
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user