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

Function test_absolute

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

Source from the content-addressed store, hash-verified

667
668 #[tokio::test]
669 async fn test_absolute() {
670 let _guard = test::prepare().await;
671
672 let records = vec![
673 Record {
674 time: Local.with_ymd_and_hms(2018, 1, 1, 1, 1, 0).unwrap(),
675 kind: Kind::ABSOLUTE,
676 metrics: [("foo".into(), 1.0), ("bar".into(), 2.0)]
677 .iter()
678 .cloned()
679 .collect(),
680 },
681 Record {
682 time: Local.with_ymd_and_hms(2018, 1, 1, 1, 2, 0).unwrap(),
683 kind: Kind::ABSOLUTE,
684 metrics: [("foo".into(), 2.0), ("bar".into(), 4.0)]
685 .iter()
686 .cloned()
687 .collect(),
688 },
689 ];
690 for r in &records {
691 save("test", r, &[Aggregation::HOUR]).await.unwrap();
692 }
693
694 let resp = get(
695 "test",
696 Kind::ABSOLUTE,
697 Aggregation::HOUR,
698 Local.with_ymd_and_hms(2018, 1, 1, 1, 0, 0).unwrap(),
699 Local.with_ymd_and_hms(2018, 1, 1, 1, 0, 0).unwrap(),
700 )
701 .await
702 .unwrap();
703
704 assert_eq!(
705 vec![Record {
706 time: Local.with_ymd_and_hms(2018, 1, 1, 1, 0, 0).unwrap(),
707 kind: Kind::ABSOLUTE,
708 metrics: [("foo".into(), 3.0), ("bar".into(), 6.0)]
709 .iter()
710 .cloned()
711 .collect(),
712 },],
713 resp
714 );
715 }
716
717 #[tokio::test]
718 async fn test_gauge() {

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