Skip to content

Commit

Permalink
reduce specificity of expected publishEvent calls
Browse files Browse the repository at this point in the history
  • Loading branch information
technobly committed Feb 4, 2022
1 parent c9d846b commit faf307c
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/unit_tests/ncp_fw_update/ncp_fw_update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ TEST_CASE("SaraNcpFwUpdate") {
//============================================

// Failed to publish case
mocks.ExpectCallFunc(publishEvent).With("spark/device/ncp/update", "started", /*flags PUBLISH_EVENT_FLAG_PRIVATE*/1).Return(false);
mocks.ExpectCallFunc(publishEvent).Return(false);
REQUIRE(ncpTest.process() == SYSTEM_ERROR_NONE);
REQUIRE(ncpTest.getSaraNcpFwUpdateState() == FW_UPDATE_STATE_FINISHED_IDLE);
REQUIRE(ncpTest.getSaraNcpFwUpdateStatus() == FW_UPDATE_STATUS_FAILED);
Expand All @@ -748,7 +748,7 @@ TEST_CASE("SaraNcpFwUpdate") {
ncpTest.setSaraNcpFwUpdateState(FW_UPDATE_STATE_SETUP_CLOUD_CONNECTED); // back to set startTimer again
ncpTest.setSaraNcpFwUpdateStatus(FW_UPDATE_STATUS_DOWNLOADING);
// Publish successful case
mocks.ExpectCallFunc(publishEvent).With("spark/device/ncp/update", "started", /*flags PUBLISH_EVENT_FLAG_PRIVATE*/1).Return(true);
mocks.ExpectCallFunc(publishEvent).Return(true);
REQUIRE(ncpTest.process() == SYSTEM_ERROR_NONE);
REQUIRE(ncpTest.getSaraNcpFwUpdateState() == FW_UPDATE_STATE_DOWNLOAD_CLOUD_DISCONNECT);
REQUIRE(ncpTest.getSaraNcpFwUpdateStatus() == FW_UPDATE_STATUS_DOWNLOADING);
Expand Down Expand Up @@ -1320,7 +1320,7 @@ TEST_CASE("SaraNcpFwUpdate") {
ncpTest.setSaraNcpFwUpdateError(SYSTEM_ERROR_NONE);
ncpMocks.setSparkCloudFlagConnected(true);
// Failed to publish case
mocks.ExpectCallFunc(publishEvent).With("spark/device/ncp/update", "success", /*flags PUBLISH_EVENT_FLAG_PRIVATE*/1).Return(false);
mocks.ExpectCallFunc(publishEvent).Return(false);
REQUIRE(ncpTest.process() == SYSTEM_ERROR_NONE);
REQUIRE(ncpTest.getSaraNcpFwUpdateState() == FW_UPDATE_STATE_FINISHED_IDLE);
REQUIRE(ncpTest.getSaraNcpFwUpdateStatus() == FW_UPDATE_STATUS_FAILED);
Expand All @@ -1331,7 +1331,7 @@ TEST_CASE("SaraNcpFwUpdate") {
ncpTest.setSaraNcpFwUpdateStatus(FW_UPDATE_STATUS_FAILED); // simulated failure
ncpTest.setSaraNcpFwUpdateError(SYSTEM_ERROR_SARA_NCP_FW_UPDATE_POWER_OFF_TIMEOUT); // simulated error
// Publish a failed status case
mocks.ExpectCallFunc(publishEvent).With("spark/device/ncp/update", "failed", /*flags PUBLISH_EVENT_FLAG_PRIVATE*/1).Return(true);
mocks.ExpectCallFunc(publishEvent).Return(true);
REQUIRE(ncpTest.process() == SYSTEM_ERROR_NONE);
REQUIRE(ncpTest.getSaraNcpFwUpdateState() == FW_UPDATE_STATE_FINISHED_IDLE);
REQUIRE(ncpTest.getSaraNcpFwUpdateStatus() == FW_UPDATE_STATUS_FAILED);
Expand All @@ -1342,7 +1342,7 @@ TEST_CASE("SaraNcpFwUpdate") {
ncpTest.setSaraNcpFwUpdateStatus(FW_UPDATE_STATUS_SUCCESS);
ncpTest.setSaraNcpFwUpdateError(SYSTEM_ERROR_NONE);
// Publish a failed status case
mocks.ExpectCallFunc(publishEvent).With("spark/device/ncp/update", "success", /*flags PUBLISH_EVENT_FLAG_PRIVATE*/1).Return(true);
mocks.ExpectCallFunc(publishEvent).Return(true);
REQUIRE(ncpTest.process() == SYSTEM_ERROR_NONE);
REQUIRE(ncpTest.getSaraNcpFwUpdateState() == FW_UPDATE_STATE_FINISHED_IDLE);
REQUIRE(ncpTest.getSaraNcpFwUpdateStatus() == FW_UPDATE_STATUS_SUCCESS);
Expand Down

0 comments on commit faf307c

Please sign in to comment.