Skip to content

Commit

Permalink
add clear closed clients test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gianluca-Casagrande-Stiga committed Jan 9, 2024
1 parent a7e03ba commit 644ce71
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions test/events.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,3 +221,20 @@ test('Test backpressure aedes published function', function (t) {
})
})
})

test('clear closed clients when the same clientId is managed by another broker', function (t) {
t.plan(1)

const clientId = 'closed-client'
const broker = aedes()

// simulate a closed client on the broker
broker.clients[clientId] = { closed: true }

// simulate the creation of the same client on another broker of the cluster
broker.publish({ topic: '$SYS/anotherbroker/new/clients', payload: clientId }, () => {
t.equal(broker.clients[clientId], undefined) // check that the closed client was removed
})

t.teardown(broker.close.bind(broker))
})

0 comments on commit 644ce71

Please sign in to comment.