summaryrefslogtreecommitdiff
path: root/test/test_fud.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_fud.cpp')
-rw-r--r--test/test_fud.cpp27
1 files changed, 25 insertions, 2 deletions
diff --git a/test/test_fud.cpp b/test/test_fud.cpp
index 0778f98..72d569a 100644
--- a/test/test_fud.cpp
+++ b/test/test_fud.cpp
@@ -15,10 +15,11 @@
* limitations under the License.
*/
-#include "fud_version.hpp"
+#include "fud_config.hpp"
#include "libfud.hpp"
#include "gtest/gtest.h"
+#include <cstdlib>
namespace fud {
@@ -32,11 +33,33 @@ TEST(FudTest, FudFud)
auto compareResult = compareMem(
fudInfo.revision.data(),
fudInfo.revision.size(),
- GitHash,
+ FudGitHash,
fudInfo.revision.size() - 1);
ASSERT_TRUE(compareResult.isOkay());
EXPECT_EQ(compareResult.getOkay(), 0);
EXPECT_EQ(fudInfo.revision[fudInfo.revision.size() - 1], '\0');
}
+TEST(FudTest, GetEnv)
+{
+ constexpr const char* testVarName = "FUD_TEST_VAR";
+ constexpr const char* testVarValue = "FUD_TEST_VALUE";
+
+ ASSERT_EQ(unsetenv(testVarName), 0);
+
+ auto fudVarResult = getEnv(nullptr);
+ ASSERT_TRUE(fudVarResult.isError());
+ ASSERT_EQ(fudVarResult.getError(), FudStatus::NullPointer);
+
+ fudVarResult = getEnv(testVarName);
+ ASSERT_TRUE(fudVarResult.isError());
+ ASSERT_EQ(fudVarResult.getError(), FudStatus::NotFound);
+
+ ASSERT_EQ(setenv(testVarName, testVarValue, 1), 0);
+ fudVarResult = getEnv(testVarName);
+ ASSERT_TRUE(fudVarResult.isOkay());
+ auto fudVar{fudVarResult.takeOkay()};
+ ASSERT_STREQ(fudVar.c_str(), testVarValue);
+}
+
} // namespace fud