diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-02-10 21:06:43 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-02-10 21:16:09 +0100 |
| commit | ec2f9869126bb5fa19c21e5272456976e7b7ad8a (patch) | |
| tree | cf4d711a8c9e4fd6cf01cd551b6acf838d6b0425 /test | |
| parent | 47eb4bb86b59bd2e28dceac857397ae8df8ed1de (diff) | |
Don't give up on backups if config.xml isn't there (#2185).
Even if it isn't, we still want to try to back up other stuff.
Previously if copying config.xml threw an exception we'd just
give up.
Diffstat (limited to 'test')
| -rw-r--r-- | test/config_test.cc | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/config_test.cc b/test/config_test.cc index 0e6a05ac0..6a65deb2e 100644 --- a/test/config_test.cc +++ b/test/config_test.cc @@ -19,13 +19,16 @@ */ +#include "lib/cinema.h" #include "lib/config.h" #include "test.h" #include <boost/test/unit_test.hpp> #include <fstream> +using std::list; using std::ofstream; +using std::make_shared; using std::string; using boost::optional; @@ -190,3 +193,26 @@ BOOST_AUTO_TEST_CASE (config_upgrade_test) BOOST_REQUIRE (!boost::filesystem::exists(dir / "2.16" / "cinemas.xml")); } + +BOOST_AUTO_TEST_CASE (config_keep_cinemas_if_making_new_config) +{ + boost::filesystem::path dir = "build/test/config_keep_cinemas_if_making_new_config"; + Config::override_path = dir; + Config::drop (); + boost::filesystem::remove_all (dir); + boost::filesystem::create_directories (dir); + + Config::instance()->write(); + + Config::instance()->add_cinema(make_shared<Cinema>("My Great Cinema", list<string>(), "", 0, 0)); + Config::instance()->write(); + + boost::filesystem::copy_file (dir / "cinemas.xml", dir / "backup_for_test.xml"); + + Config::drop (); + boost::filesystem::remove (dir / "2.16" / "config.xml"); + Config::instance(); + + check_text_file (dir / "backup_for_test.xml", dir / "cinemas.xml.1"); +} + |
