Skip to content

Commit 4ce2292

Browse files
committed
test: fix test
1 parent cd0e20e commit 4ce2292

1 file changed

Lines changed: 12 additions & 12 deletions

File tree

test/utils/log/ApiLoggerTest.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#include "log/ApiLogger.h"
22
#include "test/ApiTestCase.h"
3+
#include "update/PluginVersion.h"
34

45
namespace UKControllerPluginUtilsTest::Api {
56
class ApiLoggerTest : public UKControllerPluginTest::ApiTestCase
@@ -9,26 +10,27 @@ namespace UKControllerPluginUtilsTest::Api {
910
{
1011
}
1112

13+
const nlohmann::json expectedPluginVersionMetadata = {
14+
{"plugin_version", UKControllerPlugin::Plugin::PluginVersion::version}};
15+
1216
UKControllerPluginUtils::Log::ApiLogger logger;
1317
};
1418

1519
TEST_F(ApiLoggerTest, ItLogsSync)
1620
{
1721
const nlohmann::json expectedPayload = {
18-
{"type", "type"}, {"message", "message"}, {"plugin_version", "#VERSION_STRING#"}};
22+
{"type", "type"}, {"message", "message"}, {"metadata", expectedPluginVersionMetadata.dump()}};
1923

2024
this->ExpectApiRequest()->Post().To("plugin/logs").WithBody(expectedPayload).WillReturnCreated();
2125
logger.Log("type", "message");
2226
}
2327

2428
TEST_F(ApiLoggerTest, ItLogsSyncWithMetadata)
2529
{
26-
const nlohmann::json metadata = {{"key", "value"}};
30+
nlohmann::json metadata = {{"key", "value"}};
31+
metadata.update(expectedPluginVersionMetadata);
2732
const nlohmann::json expectedPayload = {
28-
{"type", "type"},
29-
{"message", "message"},
30-
{"metadata", metadata.dump()},
31-
{"plugin_version", "#VERSION_STRING#"}};
33+
{"type", "type"}, {"message", "message"}, {"metadata", metadata.dump()}};
3234

3335
this->ExpectApiRequest()->Post().To("plugin/logs").WithBody(expectedPayload).WillReturnCreated();
3436
logger.Log("type", "message", metadata);
@@ -37,20 +39,18 @@ namespace UKControllerPluginUtilsTest::Api {
3739
TEST_F(ApiLoggerTest, ItLogsAsync)
3840
{
3941
const nlohmann::json expectedPayload = {
40-
{"type", "type"}, {"message", "message"}, {"plugin_version", "#VERSION_STRING#"}};
42+
{"type", "type"}, {"message", "message"}, {"metadata", expectedPluginVersionMetadata.dump()}};
4143

4244
this->ExpectApiRequest()->Post().To("plugin/logs").WithBody(expectedPayload).WillReturnCreated();
4345
logger.LogAsync("type", "message");
4446
}
4547

4648
TEST_F(ApiLoggerTest, ItLogsAsyncWithMetadata)
4749
{
48-
const nlohmann::json metadata = {{"key", "value"}};
50+
nlohmann::json metadata = {{"key", "value"}};
51+
metadata.update(expectedPluginVersionMetadata);
4952
const nlohmann::json expectedPayload = {
50-
{"type", "type"},
51-
{"message", "message"},
52-
{"metadata", metadata.dump()},
53-
{"plugin_version", "#VERSION_STRING#"}};
53+
{"type", "type"}, {"message", "message"}, {"metadata", metadata.dump()}};
5454

5555
this->ExpectApiRequest()->Post().To("plugin/logs").WithBody(expectedPayload).WillReturnCreated();
5656
logger.LogAsync("type", "message", metadata);

0 commit comments

Comments
 (0)