From cc9b18cd5d2347b3bc23a02df85704d05b0627c1 Mon Sep 17 00:00:00 2001 From: vansangpfiev Date: Fri, 13 Sep 2024 12:18:05 +0700 Subject: [PATCH] fix: cortex update unit test --- engine/test/components/test_cortex_upd_cmd.cc | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/engine/test/components/test_cortex_upd_cmd.cc b/engine/test/components/test_cortex_upd_cmd.cc index 9b8f3e764..93f555535 100644 --- a/engine/test/components/test_cortex_upd_cmd.cc +++ b/engine/test/components/test_cortex_upd_cmd.cc @@ -5,9 +5,7 @@ namespace { constexpr const auto kNewReleaseFolder = "./cortex-release"; constexpr const auto kNewReleaseFile = "./cortex-release/cortexexe"; constexpr const auto kCurReleaseFile = "./cortexexe"; -std::filesystem::path GetCortexTemp() { - return std::filesystem::temp_directory_path() / "cortex_temp"; -} +constexpr const auto kCortexTemp = "./cortex_temp"; } // namespace class CortexUpdCmdTest : public ::testing::Test { @@ -31,8 +29,8 @@ class CortexUpdCmdTest : public ::testing::Test { std::filesystem::remove(kCurReleaseFile); } - if (std::filesystem::exists(GetCortexTemp())) { - std::filesystem::remove(GetCortexTemp()); + if (std::filesystem::exists(kCortexTemp)) { + std::filesystem::remove(kCortexTemp); } } }; @@ -45,12 +43,12 @@ TEST_F(CortexUpdCmdTest, replace_binary_successfully) { std::filesystem::path new_binary(kNewReleaseFile); std::filesystem::path cur_binary(kCurReleaseFile); EXPECT_TRUE(commands::ReplaceBinaryInflight(new_binary, cur_binary)); - EXPECT_TRUE(std::filesystem::exists(GetCortexTemp())); + EXPECT_TRUE(std::filesystem::exists(kCortexTemp)); } TEST_F(CortexUpdCmdTest, should_restore_old_binary_if_has_error) { std::filesystem::path new_binary("Non-exist"); std::filesystem::path cur_binary(kCurReleaseFile); EXPECT_FALSE(commands::ReplaceBinaryInflight(new_binary, cur_binary)); - EXPECT_FALSE(std::filesystem::exists(GetCortexTemp())); + EXPECT_FALSE(std::filesystem::exists(kCortexTemp)); } \ No newline at end of file