docs: catch up handoff and changelog
Build and Deploy / build-and-push (push) Successful in 5m23s

This commit is contained in:
funman300
2026-06-08 19:03:40 -07:00
parent 6193d31497
commit 7fe6ac6c1c
5 changed files with 442 additions and 52 deletions
+59
View File
@@ -114,3 +114,62 @@ fn url_encode(s: &str) -> String {
})
.collect()
}
#[cfg(test)]
mod tests {
use super::*;
fn pending(client: &MatomoClient) -> Vec<String> {
client.pending.lock().expect("pending lock").clone()
}
#[test]
fn event_buffers_encoded_matomo_query() {
let client = MatomoClient::new(
"https://analytics.example.com/",
7,
Some("alice bob".into()),
);
client.event("Game Flow", "Won+Fast", Some("draw three"), Some(42.5));
let pending = pending(&client);
assert_eq!(pending.len(), 1);
let query = &pending[0];
assert!(query.contains("idsite=7"));
assert!(query.contains("rec=1"));
assert!(query.contains("e_c=Game%20Flow"));
assert!(query.contains("e_a=Won%2BFast"));
assert!(query.contains("e_n=draw%20three"));
assert!(query.contains("e_v=42.5"));
assert!(query.contains("uid=alice%20bob"));
}
#[test]
fn event_buffer_drops_oldest_entries_when_capacity_exceeded() {
let client = MatomoClient::new("https://analytics.example.com", 1, None);
for idx in 0..101 {
client.event("Game", "Start", Some(&format!("event-{idx}")), None);
}
let pending = pending(&client);
assert_eq!(pending.len(), 51);
assert!(
pending[0].contains("event-50"),
"oldest retained event should be event-50, got {}",
pending[0]
);
assert!(
pending[50].contains("event-100"),
"newest retained event should be event-100, got {}",
pending[50]
);
}
#[test]
fn url_encode_leaves_unreserved_bytes_and_escapes_everything_else() {
assert_eq!(url_encode("AZaz09-_.~"), "AZaz09-_.~");
assert_eq!(url_encode("a b+c/d?"), "a%20b%2Bc%2Fd%3F");
}
}