~aleteoryx/muditaos

89237cb59413fc5d4ab41ebebc756ffcda23a316 — Jakub Pyszczak 5 years ago b00efa6
[EGD-5119] Fix UT service desktop

Minor code changes to get service desktop unit test working.
M module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp => module-services/service-desktop/endpoints/deviceInfo/DeviceInfoEndpoint.cpp +3 -0
@@ 29,6 29,9 @@ auto DeviceInfoEndpoint::handle(Context &context) -> void
}
auto DeviceInfoEndpoint::getDeviceInfo(Context &context) -> bool
{
    if (ownerServicePtr == nullptr) {
        return false;
    }
    vfs::FilesystemStats fsStats = vfs.getFilesystemStats();
    json11::Json updateHistory   = static_cast<ServiceDesktop *>(ownerServicePtr)->updateOS->getUpdateHistory();


M module-services/service-desktop/endpoints/update/UpdateMuditaOS.cpp => module-services/service-desktop/endpoints/update/UpdateMuditaOS.cpp +3 -0
@@ 777,6 777,9 @@ void UpdateMuditaOS::informUpdate(const updateos::UpdateState statusCode, const 
    auto msgToSend         = std::make_shared<sdesktop::UpdateOsMessage>(updateos::UpdateMessageType::UpdateInform);
    messageText            = std::string(readBuf.get());
    msgToSend->updateStats = (updateos::UpdateStats)(*this);
    if (owner == nullptr) {
        return;
    }
    sys::Bus::SendUnicast(msgToSend, app::name_desktop, owner);

    parserFSM::Context responseContext;

M module-services/service-desktop/tests/unittest.cpp => module-services/service-desktop/tests/unittest.cpp +4 -15
@@ 47,17 47,6 @@ TEST_CASE("System Update Tests")
    REQUIRE(err == updateos::UpdateError::NoError);
}

TEST_CASE("Factory Reset Test")
{
    vfs.Init();

    std::string sysdir = purefs::dir::getRootDiskPath();
    sysdir += "/factory-test/sys";
    std::string factorydir = sysdir + "/factory";
    REQUIRE(FactoryReset::DeleteDirContent(sysdir) == true);
    REQUIRE(FactoryReset::CopyDirContent(factorydir, sysdir) == true);
}

using namespace parserFSM;

TEST_CASE("Parser Test")


@@ 258,7 247,7 @@ TEST_CASE("Context class test")

    SECTION("Correct message")
    {
        auto testMessage = R"({"endpoint":6, "method":1, "uuid":12345, "body":{"test":"test"}})";
        auto testMessage = R"({"endpoint":7, "method":1, "uuid":12345, "body":{"test":"test"}})";
        std::string err;
        auto msgJson = json11::Json::parse(testMessage, err);
        REQUIRE(err.empty());


@@ 269,11 258,11 @@ TEST_CASE("Context class test")
        REQUIRE(context.getUuid() == 12345);
        REQUIRE(context.getEndpoint() == EndpointType::contacts);
        REQUIRE(context.createSimpleResponse() ==
                R"(#000000061{"body": null, "endpoint": 6, "status": 200, "uuid": "12345"})");
                R"(#000000061{"body": null, "endpoint": 7, "status": 200, "uuid": "12345"})");

        context.setResponseBody(context.getBody());
        REQUIRE(context.createSimpleResponse() ==
                R"(#000000073{"body": {"test": "test"}, "endpoint": 6, "status": 200, "uuid": "12345"})");
                R"(#000000073{"body": {"test": "test"}, "endpoint": 7, "status": 200, "uuid": "12345"})");
    }
    SECTION("Invalid message")
    {


@@ 296,7 285,7 @@ TEST_CASE("Endpoint Factory test")

    SECTION("Proper endpoint")
    {
        auto testMessage = R"({"endpoint":6, "method":1, "uuid":12345, "body":{"test":"test"}})";
        auto testMessage = R"({"endpoint":7, "method":1, "uuid":12345, "body":{"test":"test"}})";
        std::string err;
        auto msgJson = json11::Json::parse(testMessage, err);
        REQUIRE(err.empty());