fix(pico-sensor): disconnect mqtt client before testing publish

This commit is contained in:
SylvanArnold
2025-06-08 21:35:20 +02:00
parent e591516a4f
commit 9267ef2a52

View File

@@ -38,6 +38,7 @@ void test_MqttClient_Publish_Disabled(void) {
// Test that publishing fails with ERR_FAILED if not connected, even if publishing is enabled // Test that publishing fails with ERR_FAILED if not connected, even if publishing is enabled
void test_MqttClient_Publish_NotConnected(void) { void test_MqttClient_Publish_NotConnected(void) {
MqttClient_Disconnect(); // Ensure we are not connected
MqttClient_SetDoPublish(true); MqttClient_SetDoPublish(true);
int res = MqttClient_Publish((const unsigned char*)"test/topic", (const unsigned char*)"value"); int res = MqttClient_Publish((const unsigned char*)"test/topic", (const unsigned char*)"value");
TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_FAILED, res, "Publish should fail with ERR_FAILED if not connected"); TEST_ASSERT_EQUAL_INT_MESSAGE(ERR_FAILED, res, "Publish should fail with ERR_FAILED if not connected");