Skip to content
Snippets Groups Projects
env.hh 660 B
Newer Older
  • Learn to ignore specific revisions
  • #ifndef __VEREIGN_TEST_UTIL_ENV_HH
    #define __VEREIGN_TEST_UTIL_ENV_HH
    
    #include <string>
    
    #include "catch.hpp"
    #include <fmt/core.h>
    
    namespace vereign {
    namespace test {
    
    inline std::string RequireEnv(const std::string& name) {
      auto var = std::getenv(name.c_str());
      if (var == nullptr) {
        FAIL(fmt::format("{} env variable is required", name));
        return "";
      }
    
      return var;
    }
    
    inline std::string GetEnv(const std::string& name, const std::string& default_) {
      auto var = std::getenv(name.c_str());
      if (var == nullptr) {
        return default_;
      }
    
      return var;
    }
    
    } // namespace vereign
    } // namespace test
    
    #endif // __VEREIGN_TEST_UTIL_ENV_HH