MCPcopy Create free account
hub / github.com/chirpstack/chirpstack / test_counter

Function test_counter

chirpstack/src/storage/metrics.rs:620–666  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

618
619 #[tokio::test]
620 async fn test_counter() {
621 let _guard = test::prepare().await;
622
623 let records = vec![
624 Record {
625 time: Local.with_ymd_and_hms(2018, 1, 1, 1, 1, 0).unwrap(),
626 kind: Kind::COUNTER,
627 metrics: [("foo".into(), 1.0), ("bar".into(), 2.0)]
628 .iter()
629 .cloned()
630 .collect(),
631 },
632 Record {
633 time: Local.with_ymd_and_hms(2018, 1, 1, 1, 2, 0).unwrap(),
634 kind: Kind::COUNTER,
635 metrics: [("foo".into(), 2.0), ("bar".into(), 4.0)]
636 .iter()
637 .cloned()
638 .collect(),
639 },
640 ];
641 for r in &records {
642 save("test", r, &[Aggregation::HOUR]).await.unwrap();
643 }
644
645 let resp = get(
646 "test",
647 Kind::COUNTER,
648 Aggregation::HOUR,
649 Local.with_ymd_and_hms(2018, 1, 1, 1, 0, 0).unwrap(),
650 Local.with_ymd_and_hms(2018, 1, 1, 1, 0, 0).unwrap(),
651 )
652 .await
653 .unwrap();
654
655 assert_eq!(
656 vec![Record {
657 time: Local.with_ymd_and_hms(2018, 1, 1, 1, 0, 0).unwrap(),
658 kind: Kind::COUNTER,
659 metrics: [("foo".into(), 2.0), ("bar".into(), 4.0)]
660 .iter()
661 .cloned()
662 .collect(),
663 },],
664 resp
665 );
666 }
667
668 #[tokio::test]
669 async fn test_absolute() {

Callers

nothing calls this directly

Calls 4

prepareFunction · 0.85
unwrapMethod · 0.80
saveFunction · 0.70
getFunction · 0.70

Tested by

no test coverage detected