Updates todo metric when items are removed

This commit is contained in:
Ben 2025-02-12 15:39:52 +01:00
parent e8ec737285
commit a7367c2205
No known key found for this signature in database
GPG Key ID: 0F16E812E736C24B
2 changed files with 9 additions and 1 deletions

View File

@ -49,6 +49,7 @@ method pop*(t: TodoList): Future[?!Nid] {.async: (raises: []), base.} =
let item = t.nids[0]
t.nids.del(0)
t.metrics.setTodoNodes(t.nids.len)
return success(item)

View File

@ -58,7 +58,6 @@ suite "TodoList":
test "nodesExpired event updates todo metric":
await fireNodesExpiredEvent(@[nid])
let item = (await todo.pop).tryGet()
check:
metrics.todo == 1
@ -73,3 +72,11 @@ suite "TodoList":
check:
popFuture.finished
popFuture.value.tryGet() == nid
test "pop updates todo metric":
await fireNewNodesDiscoveredEvent(@[nid])
discard (await todo.pop()).tryGet()
check:
metrics.todo == 0