1 // This Source Code Form is subject to the terms of the Mozilla Public
2 // License, v. 2.0. If a copy of the MPL was not distributed with this
3 // file, You can obtain one at https://mozilla.org/MPL/2.0/.
4 
5 mod common;
6 use crate::common::*;
7 
8 use glean_core::metrics::*;
9 use glean_core::CommonMetricData;
10 
11 #[test]
stores_strings()12 fn stores_strings() {
13     let (glean, _t) = new_glean(None);
14     let metric = StringMetric::new(CommonMetricData::new("local", "string", "baseline"));
15 
16     assert_eq!(None, metric.test_get_value(&glean, "baseline"));
17 
18     metric.set(&glean, "telemetry");
19     assert_eq!(
20         "telemetry",
21         metric.test_get_value(&glean, "baseline").unwrap()
22     );
23 }
24 
25 #[test]
stores_counters()26 fn stores_counters() {
27     let (glean, _t) = new_glean(None);
28     let metric = CounterMetric::new(CommonMetricData::new("local", "counter", "baseline"));
29 
30     assert_eq!(None, metric.test_get_value(&glean, "baseline"));
31 
32     metric.add(&glean, 1);
33     assert_eq!(1, metric.test_get_value(&glean, "baseline").unwrap());
34 
35     metric.add(&glean, 2);
36     assert_eq!(3, metric.test_get_value(&glean, "baseline").unwrap());
37 }
38