Skip to content

Commit c09443c

Browse files
Add test for JSON protocol
1 parent 4fb6576 commit c09443c

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

utest/TestMqttMessagingProtocolJSON.cpp

+35-1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,40 @@ namespace {
7575
EXPECT_EQ(s.bundleVersion, "1.1");
7676
}
7777

78+
TEST_F(TestMessagingProtocolJSON, readDesiredState_activityIdIsEmpty_throwsLogicError)
79+
{
80+
// clang-format off
81+
const std::string input = R"(
82+
{
83+
"activityId": "",
84+
"timestamp": 123456789,
85+
"payload": {
86+
"domains": [
87+
{
88+
"id": "self-update",
89+
"components": [
90+
{
91+
"id": "os-image",
92+
"version": "1.1",
93+
"config": [
94+
{
95+
"key": "image",
96+
"value": "http://example.com/downloads/os-image-1.1.bin"
97+
}
98+
]
99+
}
100+
]
101+
}
102+
]
103+
}
104+
}
105+
)";
106+
// clang-format on
107+
108+
EXPECT_NO_THROW(validateJsonSyntax(input));
109+
EXPECT_THROW(ProtocolJSON().readDesiredState(input), std::logic_error);
110+
}
111+
78112
TEST_F(TestMessagingProtocolJSON, readDesiredState_missingDomain_throwsRuntimeError)
79113
{
80114
// clang-format off
@@ -196,7 +230,7 @@ namespace {
196230
"components": [
197231
{
198232
"id": "os-image",
199-
"version": "",
233+
"version": "1.0",
200234
"config": [
201235
{
202236
"key": "image",

0 commit comments

Comments
 (0)