Skip to main content

wowlab_analytics/analytics/
test_support.rs

1//! Minimal protobuf fixtures shared by analytics tests.
2
3use wowlab_types::proto;
4
5const CHUNKS: u32 = 4;
6const CI95_HALF_PERCENT_X10_000: u32 = 150;
7const ITERATIONS: u64 = 10_000;
8const MAX_DPS_X10: u32 = 150_000;
9const MEAN_DPS_X10: u32 = 123_456;
10const MIN_DPS_X10: u32 = 100_000;
11const STD_DPS_X10: u32 = 5_000;
12const TOTAL_FIGHT_TIME_MS: u64 = 300_000;
13
14#[must_use]
15pub fn make_minimal_result() -> proto::ResultViewV1 {
16    proto::ResultViewV1 {
17        core: Some(proto::ResultCoreV1 {
18            iterations: ITERATIONS,
19            chunks_completed: CHUNKS,
20            chunks_total: CHUNKS,
21            total_fight_time_ms: TOTAL_FIGHT_TIME_MS,
22            mean_dps_x10: MEAN_DPS_X10,
23            min_dps_x10: MIN_DPS_X10,
24            max_dps_x10: MAX_DPS_X10,
25            std_dps_x10: STD_DPS_X10,
26            ci95_half_pct_x10000: CI95_HALF_PERCENT_X10_000,
27        }),
28        ..Default::default()
29    }
30}
31
32#[must_use]
33pub fn make_minimal_timeline() -> proto::TimelineViewV1 {
34    proto::TimelineViewV1::default()
35}
36
37#[cfg(test)]
38mod tests {
39    use googletest::prelude::*;
40
41    use super::*;
42
43    #[gtest]
44    fn result_fixture_has_required_core() -> Result<()> {
45        let core = make_minimal_result().core.or_fail()?;
46
47        verify_that!(core.iterations, eq(ITERATIONS))?;
48
49        verify_that!(core.chunks_completed, eq(core.chunks_total))
50    }
51
52    #[gtest]
53    fn timeline_fixture_is_empty() -> Result<()> {
54        verify_true!(make_minimal_timeline() == proto::TimelineViewV1::default())
55    }
56}