diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-07-22 22:14:31 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2019-07-22 22:14:31 +0100 |
commit | db00a9699e3b12e5f1b79b55a4fd35c4e1dee163 (patch) | |
tree | 1b706ea330f7399f7c0c5cb4dc43b5f7f7ba4815 /unittests/service.cpp | |
parent | Unline git helpers and throw NetFS exceptions (diff) | |
download | netfs-gitfs-db00a9699e3b12e5f1b79b55a4fd35c4e1dee163.tar.bz2 netfs-gitfs-db00a9699e3b12e5f1b79b55a4fd35c4e1dee163.tar.xz netfs-gitfs-db00a9699e3b12e5f1b79b55a4fd35c4e1dee163.zip |
Replace hard-coded test values with properties
Diffstat (limited to 'unittests/service.cpp')
-rw-r--r-- | unittests/service.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/unittests/service.cpp b/unittests/service.cpp new file mode 100644 index 0000000..aaa9d85 --- /dev/null +++ b/unittests/service.cpp @@ -0,0 +1,56 @@ +#define BOOST_TEST_MODULE GitFS_Service +#include <boost/test/unit_test.hpp> +#include <boost/test/data/test_case.hpp> + +#include <definedDirs.h> +#include <compileTimeFormatter.h> +#include "mockDefs.h" + +using namespace GitFS; +using namespace GitFS::Test; +using namespace AdHoc::literals; + +namespace btdata = boost::unit_test::data; + +BOOST_DATA_TEST_CASE(no_repos, + btdata::make({ "", "testrepo", "no repo" }) * + btdata::make({ "", "testauth", "badkey" }), + repo, key) +{ + IceTray::DryIce s; + Client c; + BOOST_CHECK_NO_THROW(c.s->ice_ping()); + + BOOST_CHECK_THROW(c.s->connect(repo, key), NetFS::ConfigError); +} + +BOOST_DATA_TEST_CASE(badauth, + btdata::make({ "", "testAuth", "badkey" }), + key) +{ + IceTray::DryIce s({ + "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()), + "--GitFS.testrepo.authkey=testauth", + "--GitFS.testrepo.commit=7a0ccb40084c3ab31d9856e7f689c0514c28c930", + }); + Client c; + BOOST_CHECK_NO_THROW(c.s->ice_ping()); + + BOOST_CHECK_THROW(c.s->connect("testrepo", key), NetFS::AuthError); +} + +BOOST_AUTO_TEST_CASE(missing_repo) +{ + IceTray::DryIce s({ + "--GitFS.missing.gitdir=/not/here", + "--GitFS.missing.commit=7a0ccb40084c3ab31d9856e7f689c0514c28c930", + "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()), + "--GitFS.testrepo.commit=7a0ccb40084c3ab31d9856e7f689c0514c28c931", + }); + Client c; + BOOST_CHECK_NO_THROW(c.s->ice_ping()); + + BOOST_CHECK_THROW(c.s->connect("missing", {}), NetFS::ConfigError); + BOOST_CHECK_THROW(c.s->connect("testrepo", {}), NetFS::ConfigError); +} + |