@@ -49,7 +49,7 @@ void simulateOTABinaryReception(OTALogic & ota_logic, OTAData const & ota_test_d
49
49
TEST CODE
50
50
**************************************************************************************/
51
51
52
- TEST_CASE (" OTAStorage initialisation failed " , " [OTAStorage::init() -> returns false]" )
52
+ TEST_CASE (" OTAStorage initialisation fails " , " [OTAStorage::init() -> returns false]" )
53
53
{
54
54
Mock<OTAStorage> ota_storage;
55
55
@@ -65,7 +65,7 @@ TEST_CASE("OTAStorage initialisation failed ", "[OTAStorage::init() -> returns f
65
65
/* Perform test */
66
66
OTALogic ota_logic (ota_storage.get ());
67
67
68
- WHEN (" OTALogic::update() is called " )
68
+ WHEN (" OTALogic::update() is called" )
69
69
{
70
70
ota_logic.update ();
71
71
THEN (" The OTA logic should be in the 'Error' state" )
@@ -74,7 +74,42 @@ TEST_CASE("OTAStorage initialisation failed ", "[OTAStorage::init() -> returns f
74
74
}
75
75
THEN (" The OTA error should be set to OTAError::StorageInitFailed" )
76
76
{
77
- REQUIRE (ota_logic.update () == OTAError::StorageInitFailed);
77
+ REQUIRE (ota_logic.error () == OTAError::StorageInitFailed);
78
+ }
79
+ }
80
+ }
81
+
82
+ /* *************************************************************************************/
83
+
84
+ TEST_CASE (" OTAStorage opening of storage file fails " , " [OTAStorage::open() -> returns false]" )
85
+ {
86
+ Mock<OTAStorage> ota_storage;
87
+
88
+ /* Configure mock object */
89
+ When (Method (ota_storage, init)).Return (true );
90
+ When (Method (ota_storage, open)).Return (false );
91
+ Fake (Method (ota_storage, write));
92
+ Fake (Method (ota_storage, close));
93
+ Fake (Method (ota_storage, remove));
94
+ Fake (Method (ota_storage, deinit));
95
+
96
+
97
+ /* Perform test */
98
+ OTALogic ota_logic (ota_storage.get ());
99
+
100
+ WHEN (" OTALogic::update() is called and some bytes have been received" )
101
+ {
102
+ uint8_t const SOME_FAKE_DATA[16 ] = {0 };
103
+ ota_logic.onOTADataReceived (SOME_FAKE_DATA, sizeof (SOME_FAKE_DATA));
104
+ ota_logic.update ();
105
+
106
+ THEN (" The OTA logic should be in the 'Error' state" )
107
+ {
108
+ REQUIRE (ota_logic.state () == OTAState::Error);
109
+ }
110
+ THEN (" The OTA error should be set to OTAError::StorageOpenFailed" )
111
+ {
112
+ REQUIRE (ota_logic.error () == OTAError::StorageOpenFailed);
78
113
}
79
114
}
80
115
}
0 commit comments