mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-27 01:21:25 +00:00
Compute cheap diff stats on checkpoint and terminal events, roll them into run summaries, and use them for the Files Changed tab badge without fetching full file diffs.
37 lines
848 B
Rust
37 lines
848 B
Rust
use std::any::{TypeId, type_name};
|
|
|
|
use fabro_api::types::DiffSummary as ApiDiffSummary;
|
|
use fabro_types::DiffSummary;
|
|
use serde_json::json;
|
|
|
|
#[test]
|
|
fn diff_summary_reuses_canonical_type() {
|
|
assert_same_type::<ApiDiffSummary, DiffSummary>();
|
|
}
|
|
|
|
#[test]
|
|
fn diff_summary_serializes_with_required_integer_fields() {
|
|
let summary = DiffSummary {
|
|
files_changed: 3,
|
|
additions: 12,
|
|
deletions: 4,
|
|
};
|
|
assert_eq!(
|
|
serde_json::to_value(summary).unwrap(),
|
|
json!({
|
|
"files_changed": 3,
|
|
"additions": 12,
|
|
"deletions": 4,
|
|
})
|
|
);
|
|
}
|
|
|
|
fn assert_same_type<T: 'static, U: 'static>() {
|
|
assert_eq!(
|
|
TypeId::of::<T>(),
|
|
TypeId::of::<U>(),
|
|
"{} should be the same type as {}",
|
|
type_name::<T>(),
|
|
type_name::<U>()
|
|
);
|
|
}
|