test: add environment mock impl
Add environment mock implementation for use in testing.
Change-Id: I5a8efe994692a2e4436bf7f3c0155516d92b49c6
Signed-off-by: Patrick Venture <venture@google.com>
diff --git a/test/env.cpp b/test/env.cpp
new file mode 100644
index 0000000..934b9a0
--- /dev/null
+++ b/test/env.cpp
@@ -0,0 +1,31 @@
+#include "env_mock.hpp"
+
+// Set this before each test that hits a call to getEnv().
+EnvInterface* envIntf = nullptr;
+
+namespace env
+{
+
+std::string getEnv(const char* key)
+{
+ return (envIntf) ? envIntf->getEnv(key) : "";
+}
+
+std::string getEnv(const char* prefix, const SensorSet::key_type& sensor)
+{
+ return (envIntf) ? envIntf->getEnv(prefix, sensor) : "";
+}
+
+std::string getEnv(const char* prefix, const std::string& type,
+ const std::string& id)
+{
+ return (envIntf) ? envIntf->getEnv(prefix, type, id) : "";
+}
+
+std::string getIndirectID(std::string path, const std::string& fileSuffix,
+ const SensorSet::key_type& sensor)
+{
+ return (envIntf) ? envIntf->getIndirectID(path, fileSuffix, sensor) : "";
+}
+
+} // namespace env