From 7938112f5c6d8b95306051338354185cfc07fb65 Mon Sep 17 00:00:00 2001 From: Henry Winkel Date: Thu, 26 Oct 2023 15:02:01 +0200 Subject: [PATCH] ADD: added test_podInfo and a bug fix --- CMakeLists.txt | 3 +++ libs/yaml-cpp | 2 +- src/kubecontrol/PodInfo.cpp | 4 +--- tests/test_podInfo.cpp | 36 ++++++++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+), 4 deletions(-) create mode 100644 tests/test_podInfo.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d69c803..3997d85 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,5 +112,8 @@ IF (${TEST_KUBECONTROL_LIBRARY}) target_link_libraries(test_podcontroller Catch2::Catch2 kubecontrol ) catch_discover_tests(test_podcontroller) + add_executable(test_podInfo tests/test_podInfo.cpp) + target_link_libraries(test_podInfo Catch2::Catch2 kubecontrol ) + catch_discover_tests(test_podInfo) ENDIF() diff --git a/libs/yaml-cpp b/libs/yaml-cpp index f791b95..35b4498 160000 --- a/libs/yaml-cpp +++ b/libs/yaml-cpp @@ -1 +1 @@ -Subproject commit f791b955d8649751421911048a7c9dd967689811 +Subproject commit 35b4498026b6293bfadc75f9ee325cb16d6975af diff --git a/src/kubecontrol/PodInfo.cpp b/src/kubecontrol/PodInfo.cpp index efd1fcd..9b1ea09 100644 --- a/src/kubecontrol/PodInfo.cpp +++ b/src/kubecontrol/PodInfo.cpp @@ -25,11 +25,9 @@ namespace kubecontrol void PodInfo::update(std::string response) { - - nlohmann::json j; try { - j = nlohmann::json::parse(response); + nlohmann::json j = nlohmann::json::parse(response); if (j.contains("items")) { diff --git a/tests/test_podInfo.cpp b/tests/test_podInfo.cpp new file mode 100644 index 0000000..4773a90 --- /dev/null +++ b/tests/test_podInfo.cpp @@ -0,0 +1,36 @@ + + + +#include "kubecontrol/PodController.hpp" +#include "nlohmann/json_fwd.hpp" +#define CATCH_CONFIG_MAIN +#include +#include + + +SCENARIO("Testing the SimCore Sensor") +{ + kubecontrol::PodController podc("docs/config"); + auto tmp = podc.getInfoForPod("webapp"); + LOG_S(INFO)<