Increase coverage by subscribing to more than one topic and unsubscribing afterwards.
This commit is contained in:
parent
13056f9ce8
commit
883a3cc476
1 changed files with 21 additions and 1 deletions
|
@ -16,6 +16,20 @@ bool err_handler(MQTTHandle *handle, MQTTErrorCode error) {
|
|||
|
||||
void callback(MQTTHandle *handle, char *topic, char *payload) {
|
||||
LOG("Received publish: %s -> %s", topic, payload);
|
||||
|
||||
MQTTStatus result = mqtt_unsubscribe(handle, "testsuite/mqtt/test");
|
||||
if (result != MQTT_STATUS_OK) {
|
||||
LOG("Could not unsubscribe test");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
result = mqtt_unsubscribe(handle, "testsuite/mqtt/test2");
|
||||
if (result != MQTT_STATUS_OK) {
|
||||
LOG("Could not unsubscribe test 2");
|
||||
exit(1);
|
||||
}
|
||||
sleep(1);
|
||||
|
||||
leave = true;
|
||||
}
|
||||
|
||||
|
@ -25,7 +39,13 @@ void mqtt_connected(MQTTHandle *handle, void *context) {
|
|||
LOG("Trying subscribe on testsuite/mqtt/test...");
|
||||
MQTTStatus result = mqtt_subscribe(handle, "testsuite/mqtt/test", callback);
|
||||
if (result != MQTT_STATUS_OK) {
|
||||
LOG("Could not subscribe");
|
||||
LOG("Could not subscribe test");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
result = mqtt_subscribe(handle, "testsuite/mqtt/test2", callback);
|
||||
if (result != MQTT_STATUS_OK) {
|
||||
LOG("Could not subscribe test 2");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue