Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[question] does the test "unsubscribe throws error" valid? #940

Open
gnought opened this issue Feb 16, 2024 · 3 comments
Open

[question] does the test "unsubscribe throws error" valid? #940

gnought opened this issue Feb 16, 2024 · 3 comments
Labels

Comments

@gnought
Copy link
Collaborator

gnought commented Feb 16, 2024

test('unsubscribe throws error', function (t) {
t.plan(2)
const broker = aedes()
t.teardown(broker.close.bind(broker))
broker.on('client', function (client) {
client.subscribe({
topic: 'hello',
qos: 0
}, function (err) {
t.error(err, 'no error')
broker.unsubscribe = function (topic, func, done) {
done(new Error('error'))
}
client.unsubscribe({
topic: 'hello',
qos: 0
}, function () {
t.pass('throws error')
})
})
})
connect(setup(broker))
})

The mocked broker.unsubscribe is only called by broker.close.

  1. Does it expect to be called by client.subscribe ?
  2. The Error does not be raised in client error event. Bug?
  3. The callback in client.subscribe does not contain any error argument, does the message in t.pass make sense?
@robertsLando
Copy link
Member

By reading it makes no sense to me too. I think it should be something like:

client.unsubscribe({ 
         topic: 'hello', 
         qos: 0 
       }, function (err) { 
         t.equal(err.message, 'error', 'throws error') 
       }) 

@gnought
Copy link
Collaborator Author

gnought commented Feb 16, 2024

@robertsLando so do I, however the callback call doesn't have err parameter.

@robertsLando
Copy link
Member

I should try it so, I dunno sincerly... let me know if you fix it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants