substreams_sink_prometheus/
helpers.rs

1use crate::{PrometheusOperation, PrometheusOperations};
2
3impl PrometheusOperations {
4    pub fn push(&mut self, operation: PrometheusOperation) {
5        self.operations.push(operation);
6    }
7
8    pub fn extend(&mut self, operations: Vec<PrometheusOperation>) {
9        self.operations.extend(operations);
10    }
11}
12
13#[cfg(test)]
14mod tests {
15    use crate::{Counter, PrometheusOperations};
16
17    #[test]
18    fn test_push() {
19        let mut prom_ops: PrometheusOperations = Default::default();
20        let mut counter = Counter::from("custom_counter");
21        prom_ops.push(counter.inc());
22        prom_ops.push(counter.inc());
23
24        assert_eq!(prom_ops.operations.len(), 2);
25    }
26
27    #[test]
28    fn test_extend() {
29        let mut prom_ops: PrometheusOperations = Default::default();
30        let mut counter = Counter::from("custom_counter");
31        prom_ops.extend(vec![counter.inc(), counter.inc()]);
32
33        assert_eq!(prom_ops.operations.len(), 2);
34    }
35}