014-configuration.cpp 970 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "catch.hpp"
  2. #include "test-utils.h"
  3. #include "config/utils.h"
  4. #include "utils/uri.h"
  5. #include <boost/filesystem.hpp>
  6. #include <sstream>
  7. namespace sys = boost::system;
  8. namespace fs = boost::filesystem;
  9. namespace st = syncspirit::test;
  10. using namespace syncspirit;
  11. TEST_CASE("default config is OK", "[config]") {
  12. auto dir = fs::current_path() / fs::unique_path();
  13. fs::create_directory(dir);
  14. auto dir_guard = st::path_guard_t(dir);
  15. auto cfg_path = dir / "syncspirit.toml";
  16. auto cfg_opt = config::generate_config(cfg_path);
  17. REQUIRE(cfg_opt);
  18. auto &cfg = cfg_opt.value();
  19. std::stringstream out;
  20. SECTION("serialize default") {
  21. auto r = config::serialize(cfg, out);
  22. CHECK(r);
  23. INFO(out.str());
  24. CHECK(out.str().find("~") == std::string::npos);
  25. auto cfg_opt = config::get_config(out, cfg_path);
  26. CHECK(cfg_opt);
  27. auto cfg2 = cfg_opt.value();
  28. CHECK(cfg == cfg2);
  29. }
  30. }