modules/hyprland/backend: handle empty json responses

Fixes https://github.com/Alexays/Waybar/issues/3388
This commit is contained in:
Austin Horstman
2024-06-28 13:11:50 -05:00
parent f6482c36dc
commit c08660d837
3 changed files with 21 additions and 3 deletions

View File

@ -1,4 +1,3 @@
#include <cstdlib>
#if __has_include(<catch2/catch_test_macros.hpp>)
#include <catch2/catch_test_macros.hpp>
#else
@ -6,7 +5,6 @@
#endif
#include "fixtures/IPCTestFixture.hpp"
#include "modules/hyprland/backend.hpp"
namespace fs = std::filesystem;
namespace hyprland = waybar::modules::hyprland;
@ -53,3 +51,11 @@ TEST_CASE_METHOD(IPCTestFixture, "XDGRuntimeDirExistsNoHyprDir", "[getSocketFold
// Assert expected result
REQUIRE(actualPath == expectedPath);
}
TEST_CASE_METHOD(IPCMock, "getSocket1JsonReply handles empty response", "[getSocket1JsonReply]") {
std::string request = "test_request";
Json::Value jsonResponse = getSocket1JsonReply(request);
REQUIRE(jsonResponse.isNull());
}