Skip to content

Commit

Permalink
test(mqtt_history): totals
Browse files Browse the repository at this point in the history
  • Loading branch information
EdJoPaTo committed May 22, 2024
1 parent 1e5e422 commit 706af9b
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/interactive/mqtt_history.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,11 @@ impl MqttHistory {
pub fn count_topics_and_messages_below(&self, topic: &str) -> (usize, usize) {
let mut topics: usize = 0;
let mut messages: usize = 0;
for (_, id) in self.ids.iter().filter(|(key, _)| key.starts_with(topic)) {
for (_, id) in self
.ids
.iter()
.filter(|(key, _)| is_topic_below(topic, key))
{
let node = self.tree.get(*id).unwrap();
let Topic { history, .. } = node.value();

Expand Down Expand Up @@ -245,6 +249,13 @@ fn count_works() {
assert_eq!(messages, 2);
}

#[test]
fn total_works() {
let example = MqttHistory::example();
assert_eq!(example.total_topics(), 4);
assert_eq!(example.total_messages(), 5);
}

#[test]
fn tree_items_works() {
let example = MqttHistory::example();
Expand Down

0 comments on commit 706af9b

Please sign in to comment.