diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2020-08-22 15:26:11 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2020-08-22 15:26:11 +0100 |
commit | f759884235b4594c4f960ea0c587697eef717665 (patch) | |
tree | 92f3b95e99fac6688a6d9cec88b6553cb77f0c60 /unittests | |
parent | Update to new NetFS interface (diff) | |
download | netfs-gitfs-f759884235b4594c4f960ea0c587697eef717665.tar.bz2 netfs-gitfs-f759884235b4594c4f960ea0c587697eef717665.tar.xz netfs-gitfs-f759884235b4594c4f960ea0c587697eef717665.zip |
Clang-format
Diffstat (limited to 'unittests')
-rw-r--r-- | unittests/config.cpp | 71 | ||||
-rw-r--r-- | unittests/core.cpp | 147 | ||||
-rw-r--r-- | unittests/mockDefs.cpp | 15 | ||||
-rw-r--r-- | unittests/mockDefs.h | 23 | ||||
-rw-r--r-- | unittests/service.cpp | 31 |
5 files changed, 135 insertions, 152 deletions
diff --git a/unittests/config.cpp b/unittests/config.cpp index db7570e..20a025a 100644 --- a/unittests/config.cpp +++ b/unittests/config.cpp @@ -1,10 +1,10 @@ #define BOOST_TEST_MODULE GitFS_Config -#include <boost/test/unit_test.hpp> #include <boost/test/data/test_case.hpp> +#include <boost/test/unit_test.hpp> -#include <definedDirs.h> -#include <compileTimeFormatter.h> #include "mockDefs.h" +#include <compileTimeFormatter.h> +#include <definedDirs.h> using namespace GitFS; using namespace GitFS::Test; @@ -13,34 +13,28 @@ using namespace AdHoc::literals; namespace btdata = boost::unit_test::data; class IdsIce : public IceTray::DryIce { - public: - IdsIce(const char * uid, const char * gid) : IceTray::DryIce({ - "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()), - "--GitFS.testrepo.authkey=%?"_fmt("testauth"), - "--GitFS.testrepo.gid=%?"_fmt(gid), - "--GitFS.testrepo.uid=%?"_fmt(uid), - "--GitFS.testrepo.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c930", +public: + IdsIce(const char * uid, const char * gid) : + IceTray::DryIce({ + "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()), + "--GitFS.testrepo.authkey=%?"_fmt("testauth"), + "--GitFS.testrepo.gid=%?"_fmt(gid), + "--GitFS.testrepo.uid=%?"_fmt(uid), + "--GitFS.testrepo.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c930", }) - {} + { + } }; -const auto USERS = btdata::make({ "root", "gituser", "www" }); -const auto GROUPS = btdata::make({ "root", "gitgroup", "www" }); -const auto DIRS = btdata::make({ "/", "/src", "/unittests/fixtures" }); -const auto FILES = btdata::make({ - "/Jamroot.jam", "/src/repo.cpp", "/unittests/fixtures/executable" }); -const auto LINKS = btdata::make({ "/unittests/fixtures/symlink" }); -const auto COMMITISHS = btdata::make({ - "", - "master", - "origin/master", - "testcommit", - "7a0ccb40084c3ab31d9856e7f689c0514c28c930" -}); +const auto USERS = btdata::make({"root", "gituser", "www"}); +const auto GROUPS = btdata::make({"root", "gitgroup", "www"}); +const auto DIRS = btdata::make({"/", "/src", "/unittests/fixtures"}); +const auto FILES = btdata::make({"/Jamroot.jam", "/src/repo.cpp", "/unittests/fixtures/executable"}); +const auto LINKS = btdata::make({"/unittests/fixtures/symlink"}); +const auto COMMITISHS + = btdata::make({"", "master", "origin/master", "testcommit", "7a0ccb40084c3ab31d9856e7f689c0514c28c930"}); -BOOST_DATA_TEST_CASE(uid_gid_override_getattr, - USERS * GROUPS * (DIRS + FILES + LINKS), - uid, gid, path) +BOOST_DATA_TEST_CASE(uid_gid_override_getattr, USERS * GROUPS *(DIRS + FILES + LINKS), uid, gid, path) { IdsIce s(uid, gid); VolumeClient c; @@ -51,9 +45,7 @@ BOOST_DATA_TEST_CASE(uid_gid_override_getattr, BOOST_CHECK_EQUAL(attr.gid, gid); } -BOOST_DATA_TEST_CASE(uid_gid_override_fgetattr, - USERS * GROUPS * FILES, - uid, gid, path) +BOOST_DATA_TEST_CASE(uid_gid_override_fgetattr, USERS * GROUPS * FILES, uid, gid, path) { IdsIce s(uid, gid); VolumeClient c; @@ -66,9 +58,7 @@ BOOST_DATA_TEST_CASE(uid_gid_override_fgetattr, file->close(); } -BOOST_DATA_TEST_CASE(uid_gid_override_list, - USERS * GROUPS * DIRS, - uid, gid, path) +BOOST_DATA_TEST_CASE(uid_gid_override_list, USERS * GROUPS * DIRS, uid, gid, path) { IdsIce s(uid, gid); VolumeClient c; @@ -84,12 +74,12 @@ BOOST_DATA_TEST_CASE(uid_gid_override_list, dir->close(); } -BOOST_DATA_TEST_CASE(commitishs, COMMITISHS * (FILES + DIRS), commitish, path) +BOOST_DATA_TEST_CASE(commitishs, COMMITISHS *(FILES + DIRS), commitish, path) { IceTray::DryIce di({ - "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()), - "--GitFS.testrepo.authkey=%?"_fmt("testauth"), - "--GitFS.testrepo.commitish=%?"_fmt(commitish), + "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()), + "--GitFS.testrepo.authkey=%?"_fmt("testauth"), + "--GitFS.testrepo.commitish=%?"_fmt(commitish), }); VolumeClient c; BOOST_CHECK_NO_THROW(c.v->ice_ping()); @@ -99,11 +89,10 @@ BOOST_DATA_TEST_CASE(commitishs, COMMITISHS * (FILES + DIRS), commitish, path) BOOST_DATA_TEST_CASE(bad_commitishs, FILES, commitish) // File paths aren't commitishs { IceTray::DryIce di({ - "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()), - "--GitFS.testrepo.authkey=%?"_fmt("testauth"), - "--GitFS.testrepo.commitish=%?"_fmt(commitish), + "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()), + "--GitFS.testrepo.authkey=%?"_fmt("testauth"), + "--GitFS.testrepo.commitish=%?"_fmt(commitish), }); Client c; BOOST_CHECK_THROW(c.s->connect("testrepo", "testauth"), NetFS::ConfigError); } - diff --git a/unittests/core.cpp b/unittests/core.cpp index ba25e88..9cd7552 100644 --- a/unittests/core.cpp +++ b/unittests/core.cpp @@ -1,22 +1,24 @@ #define BOOST_TEST_MODULE GitFS_Core -#include <boost/test/unit_test.hpp> #include <boost/test/data/test_case.hpp> +#include <boost/test/unit_test.hpp> #include "mockDefs.h" -#include "sys/stat.h" #include "sys/fcntl.h" +#include "sys/stat.h" using namespace GitFS; using namespace GitFS::Test; namespace std { - std::ostream & operator<<(std::ostream & strm, const std::tuple<std::string, int> &) + std::ostream & + operator<<(std::ostream & strm, const std::tuple<std::string, int> &) { return strm; } template<typename T> - std::ostream & operator<<(std::ostream & strm, const std::vector<T> & v) + std::ostream & + operator<<(std::ostream & strm, const std::vector<T> & v) { strm << "[ "; for (const auto & e : v) { @@ -33,19 +35,23 @@ namespace std { #define BOOST_CHECK_THROW_SYSTEMERROR(CODE, ERRNO) \ try { \ BOOST_TEST_CHECKPOINT(""); \ - [&](){ CODE ; }(); \ + [&]() { \ + CODE; \ + }(); \ BOOST_ERROR("No exception thrown, NetFS::SystemError expected"); \ - } catch (const NetFS::SystemError & se) { \ + } \ + catch (const NetFS::SystemError & se) { \ BOOST_CHECK_EQUAL(se.syserrno, ERRNO); \ - } catch (...) { \ + } \ + catch (...) { \ BOOST_ERROR("NetFS::SystemError not thrown"); \ - }\ + } BOOST_TEST_GLOBAL_FIXTURE(Service); BOOST_FIXTURE_TEST_SUITE(volume, VolumeClient); -BOOST_AUTO_TEST_CASE( unsupported_rofs_ops ) +BOOST_AUTO_TEST_CASE(unsupported_rofs_ops) { BOOST_CHECK_THROW_SYSTEMERROR(v->create(env, {}, {}, {}), EROFS); BOOST_CHECK_THROW_SYSTEMERROR(v->truncate(env, {}, {}), EROFS); @@ -61,7 +67,7 @@ BOOST_AUTO_TEST_CASE( unsupported_rofs_ops ) BOOST_CHECK_THROW_SYSTEMERROR(v->utimens(env, {}, {}, {}, {}, {}), EROFS); } -BOOST_AUTO_TEST_CASE( statfs ) +BOOST_AUTO_TEST_CASE(statfs) { // Don't know what this should return, but it shouldn't error given a valid path BOOST_CHECK_THROW_SYSTEMERROR(v->statfs(env, ""), EINVAL); @@ -69,42 +75,41 @@ BOOST_AUTO_TEST_CASE( statfs ) } namespace btdata = boost::unit_test::data; -const auto INVALIDPATHS = btdata::make({ - "" -}); +const auto INVALIDPATHS = btdata::make({""}); const auto BADPATHS = btdata::make({ - "/.", - "/../", - ".", - "..", - "../", + "/.", + "/../", + ".", + "..", + "../", }); const auto DIRPATHS = btdata::make({ - "/", - "/src", - "/unittests", - "/unittests/fixtures", + "/", + "/src", + "/unittests", + "/unittests/fixtures", }); const auto REGPATHS = btdata::make({ - "/.gitignore", - "/Jamroot.jam", - "/src/Jamfile.jam", - "/unittests/Jamfile.jam", + "/.gitignore", + "/Jamroot.jam", + "/src/Jamfile.jam", + "/unittests/Jamfile.jam", }); const auto EXECPATHS = btdata::make({ - "/unittests/fixtures/executable", + "/unittests/fixtures/executable", }); const auto LINKPATHS = btdata::make({ - "/unittests/fixtures/symlink", + "/unittests/fixtures/symlink", }); const auto MISSINGPATHS = btdata::make({ - "/.missing", - "/missing", - "/src/missing", - "/unittests/fixtures/missing", + "/.missing", + "/missing", + "/src/missing", + "/unittests/fixtures/missing", }); -BOOST_DATA_TEST_CASE(accessWrite, INVALIDPATHS + DIRPATHS + REGPATHS + EXECPATHS + LINKPATHS + MISSINGPATHS + BADPATHS, path) +BOOST_DATA_TEST_CASE( + accessWrite, INVALIDPATHS + DIRPATHS + REGPATHS + EXECPATHS + LINKPATHS + MISSINGPATHS + BADPATHS, path) { BOOST_CHECK_EQUAL(EACCES, v->access(env, path, W_OK)); } @@ -128,24 +133,23 @@ BOOST_DATA_TEST_CASE(accessExec, EXECPATHS, path) BOOST_CHECK_EQUAL(0, v->access(env, path, R_OK)); BOOST_CHECK_EQUAL(0, v->access(env, path, X_OK)); } -BOOST_DATA_TEST_CASE( accessInval, INVALIDPATHS * btdata::make({ R_OK, X_OK }), path, mode) +BOOST_DATA_TEST_CASE(accessInval, INVALIDPATHS * btdata::make({R_OK, X_OK}), path, mode) { BOOST_CHECK_EQUAL(EINVAL, v->access(env, path, mode)); } -BOOST_DATA_TEST_CASE( accessBad, BADPATHS * btdata::make({ R_OK, X_OK }), path, mode) +BOOST_DATA_TEST_CASE(accessBad, BADPATHS * btdata::make({R_OK, X_OK}), path, mode) { BOOST_CHECK_EQUAL(ENOENT, v->access(env, path, mode)); } -BOOST_DATA_TEST_CASE( statInval, INVALIDPATHS, path ) +BOOST_DATA_TEST_CASE(statInval, INVALIDPATHS, path) { BOOST_CHECK_THROW_SYSTEMERROR(v->getattr(env, path), EINVAL); } -BOOST_DATA_TEST_CASE( statBad, BADPATHS, path ) +BOOST_DATA_TEST_CASE(statBad, BADPATHS, path) { BOOST_CHECK_THROW_SYSTEMERROR(v->getattr(env, path), ENOENT); } - const auto DIRMODE = S_IFDIR | S_IRUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; const auto FILEMODE = S_IFREG | S_IRUSR | S_IRGRP | S_IROTH; const auto EXECMODE = FILEMODE | S_IXUSR | S_IXGRP | S_IXOTH; @@ -154,7 +158,7 @@ const time_t COMMIT_TIME = 1563621030; const std::string USER = "root"; const std::string GROUP = "root"; -BOOST_DATA_TEST_CASE( statDirs, DIRPATHS, path ) +BOOST_DATA_TEST_CASE(statDirs, DIRPATHS, path) { const auto attr = v->getattr(env, path); BOOST_CHECK_EQUAL(DIRMODE, attr.mode); @@ -165,7 +169,7 @@ BOOST_DATA_TEST_CASE( statDirs, DIRPATHS, path ) BOOST_CHECK_EQUAL(USER, attr.uid); BOOST_CHECK_EQUAL(GROUP, attr.gid); } -BOOST_DATA_TEST_CASE( statFiles, REGPATHS, path ) +BOOST_DATA_TEST_CASE(statFiles, REGPATHS, path) { const auto attr = v->getattr(env, path); BOOST_CHECK_EQUAL(FILEMODE, attr.mode); @@ -176,7 +180,7 @@ BOOST_DATA_TEST_CASE( statFiles, REGPATHS, path ) BOOST_CHECK_EQUAL(USER, attr.uid); BOOST_CHECK_EQUAL(GROUP, attr.gid); } -BOOST_DATA_TEST_CASE( statExecs, EXECPATHS, path ) +BOOST_DATA_TEST_CASE(statExecs, EXECPATHS, path) { const auto attr = v->getattr(env, path); BOOST_CHECK_EQUAL(EXECMODE, attr.mode); @@ -187,7 +191,7 @@ BOOST_DATA_TEST_CASE( statExecs, EXECPATHS, path ) BOOST_CHECK_EQUAL(USER, attr.uid); BOOST_CHECK_EQUAL(GROUP, attr.gid); } -BOOST_DATA_TEST_CASE( statSymlink, LINKPATHS, path ) +BOOST_DATA_TEST_CASE(statSymlink, LINKPATHS, path) { const auto attr = v->getattr(env, path); BOOST_CHECK_EQUAL(LINKMODE, attr.mode); @@ -199,40 +203,39 @@ BOOST_DATA_TEST_CASE( statSymlink, LINKPATHS, path ) BOOST_CHECK_EQUAL(GROUP, attr.gid); } - -BOOST_DATA_TEST_CASE( readlinkInval, INVALIDPATHS + DIRPATHS + REGPATHS + EXECPATHS, path ) +BOOST_DATA_TEST_CASE(readlinkInval, INVALIDPATHS + DIRPATHS + REGPATHS + EXECPATHS, path) { BOOST_CHECK_THROW_SYSTEMERROR(v->readlink(env, path), EINVAL); } -BOOST_DATA_TEST_CASE( readlinkBad, BADPATHS + MISSINGPATHS, path ) +BOOST_DATA_TEST_CASE(readlinkBad, BADPATHS + MISSINGPATHS, path) { BOOST_CHECK_THROW_SYSTEMERROR(v->readlink(env, path), ENOENT); } -BOOST_DATA_TEST_CASE( readlink, LINKPATHS ^ btdata::make({ "executable" }), path, target ) +BOOST_DATA_TEST_CASE(readlink, LINKPATHS ^ btdata::make({"executable"}), path, target) { BOOST_CHECK_EQUAL(target, v->readlink(env, path)); } - -BOOST_DATA_TEST_CASE( openDirInval, INVALIDPATHS, path ) +BOOST_DATA_TEST_CASE(openDirInval, INVALIDPATHS, path) { BOOST_CHECK_THROW_SYSTEMERROR(v->opendir(env, path), EINVAL); } -BOOST_DATA_TEST_CASE( openDirBad, BADPATHS + MISSINGPATHS, path ) +BOOST_DATA_TEST_CASE(openDirBad, BADPATHS + MISSINGPATHS, path) { BOOST_CHECK_THROW_SYSTEMERROR(v->opendir(env, path), ENOENT); } -BOOST_DATA_TEST_CASE( openDirNotDir, REGPATHS + LINKPATHS + EXECPATHS, path ) +BOOST_DATA_TEST_CASE(openDirNotDir, REGPATHS + LINKPATHS + EXECPATHS, path) { BOOST_CHECK_THROW_SYSTEMERROR(v->opendir(env, path), ENOTDIR); } const auto DIRCONTENTS = btdata::make<std::vector<std::string>>({ - {".gitignore", "Jamroot.jam", "src", "unittests"}, - {"Jamfile.jam", "blob.cpp", "blob.h", "dir.cpp", "dir.h", "git.cpp", "git.h", "main.cpp", "repo.cpp", "repo.h", "repoList.cpp", "repoList.h"}, - {"Jamfile.jam", "core.cpp", "fixtures", "mockDefs.cpp", "mockDefs.h"}, - {"executable", "symlink"}, + {".gitignore", "Jamroot.jam", "src", "unittests"}, + {"Jamfile.jam", "blob.cpp", "blob.h", "dir.cpp", "dir.h", "git.cpp", "git.h", "main.cpp", "repo.cpp", "repo.h", + "repoList.cpp", "repoList.h"}, + {"Jamfile.jam", "core.cpp", "fixtures", "mockDefs.cpp", "mockDefs.h"}, + {"executable", "symlink"}, }); -BOOST_DATA_TEST_CASE( openDirRead, DIRPATHS ^ DIRCONTENTS, path, contents ) +BOOST_DATA_TEST_CASE(openDirRead, DIRPATHS ^ DIRCONTENTS, path, contents) { auto dir = v->opendir(env, path); BOOST_REQUIRE(dir); @@ -242,12 +245,15 @@ BOOST_DATA_TEST_CASE( openDirRead, DIRPATHS ^ DIRCONTENTS, path, contents ) dir->close(); } const auto DIRCONTENTMODES = btdata::make<std::vector<std::tuple<std::string, int>>>({ - {{".gitignore", FILEMODE}, {"Jamroot.jam", FILEMODE}, {"src",DIRMODE}, {"unittests", DIRMODE}}, - {{"Jamfile.jam", FILEMODE}, {"blob.cpp", FILEMODE}, {"blob.h", FILEMODE}, {"dir.cpp", FILEMODE}, {"dir.h", FILEMODE}, {"git.cpp", FILEMODE}, {"git.h", FILEMODE}, {"main.cpp", FILEMODE}, {"repo.cpp", FILEMODE}, {"repo.h", FILEMODE}, {"repoList.cpp", FILEMODE}, {"repoList.h", FILEMODE}}, - {{"Jamfile.jam", FILEMODE}, {"core.cpp", FILEMODE}, {"fixtures", DIRMODE}, {"mockDefs.cpp", FILEMODE}, {"mockDefs.h", FILEMODE}}, - {{"executable", EXECMODE}, {"symlink", LINKMODE}}, + {{".gitignore", FILEMODE}, {"Jamroot.jam", FILEMODE}, {"src", DIRMODE}, {"unittests", DIRMODE}}, + {{"Jamfile.jam", FILEMODE}, {"blob.cpp", FILEMODE}, {"blob.h", FILEMODE}, {"dir.cpp", FILEMODE}, + {"dir.h", FILEMODE}, {"git.cpp", FILEMODE}, {"git.h", FILEMODE}, {"main.cpp", FILEMODE}, + {"repo.cpp", FILEMODE}, {"repo.h", FILEMODE}, {"repoList.cpp", FILEMODE}, {"repoList.h", FILEMODE}}, + {{"Jamfile.jam", FILEMODE}, {"core.cpp", FILEMODE}, {"fixtures", DIRMODE}, {"mockDefs.cpp", FILEMODE}, + {"mockDefs.h", FILEMODE}}, + {{"executable", EXECMODE}, {"symlink", LINKMODE}}, }); -BOOST_DATA_TEST_CASE( openDirList, DIRPATHS ^ DIRCONTENTMODES, path, contents ) +BOOST_DATA_TEST_CASE(openDirList, DIRPATHS ^ DIRCONTENTMODES, path, contents) { auto dir = v->opendir(env, path); BOOST_REQUIRE(dir); @@ -260,8 +266,8 @@ BOOST_DATA_TEST_CASE( openDirList, DIRPATHS ^ DIRCONTENTMODES, path, contents ) BOOST_CHECK_EQUAL(COMMIT_TIME, li->second.mtime); BOOST_CHECK_EQUAL(COMMIT_TIME, li->second.ctime); BOOST_CHECK_EQUAL(COMMIT_TIME, li->second.atime); - BOOST_CHECK_EQUAL(USER, li->second.uid); - BOOST_CHECK_EQUAL(GROUP, li->second.gid); + BOOST_CHECK_EQUAL(USER, li->second.uid); + BOOST_CHECK_EQUAL(GROUP, li->second.gid); if (S_ISREG(li->second.mode)) { BOOST_CHECK_LE(4, li->second.size); } @@ -269,24 +275,23 @@ BOOST_DATA_TEST_CASE( openDirList, DIRPATHS ^ DIRCONTENTMODES, path, contents ) dir->close(); } - -BOOST_DATA_TEST_CASE( openInval, INVALIDPATHS, path ) +BOOST_DATA_TEST_CASE(openInval, INVALIDPATHS, path) { BOOST_CHECK_THROW_SYSTEMERROR(v->open(env, path, O_RDONLY), EINVAL); } -BOOST_DATA_TEST_CASE( openBad, BADPATHS + MISSINGPATHS, path ) +BOOST_DATA_TEST_CASE(openBad, BADPATHS + MISSINGPATHS, path) { BOOST_CHECK_THROW_SYSTEMERROR(v->open(env, path, O_RDONLY), ENOENT); } -BOOST_DATA_TEST_CASE( openNotFileDir, DIRPATHS, path ) +BOOST_DATA_TEST_CASE(openNotFileDir, DIRPATHS, path) { BOOST_CHECK_THROW_SYSTEMERROR(v->open(env, path, O_RDONLY), EISDIR); } -BOOST_DATA_TEST_CASE( openNotFileLink, LINKPATHS, path ) +BOOST_DATA_TEST_CASE(openNotFileLink, LINKPATHS, path) { BOOST_CHECK_THROW_SYSTEMERROR(v->open(env, path, O_RDONLY), ELOOP); } -BOOST_DATA_TEST_CASE( openFileROFSOps, REGPATHS + EXECPATHS, path ) +BOOST_DATA_TEST_CASE(openFileROFSOps, REGPATHS + EXECPATHS, path) { auto f = v->open(env, path, O_RDONLY); BOOST_REQUIRE(f); @@ -295,7 +300,7 @@ BOOST_DATA_TEST_CASE( openFileROFSOps, REGPATHS + EXECPATHS, path ) f->close(); } -BOOST_DATA_TEST_CASE( openFileGetAttr, REGPATHS + EXECPATHS, path ) +BOOST_DATA_TEST_CASE(openFileGetAttr, REGPATHS + EXECPATHS, path) { auto f = v->open(env, path, O_RDONLY); BOOST_REQUIRE(f); @@ -309,7 +314,7 @@ BOOST_DATA_TEST_CASE( openFileGetAttr, REGPATHS + EXECPATHS, path ) f->close(); } -BOOST_DATA_TEST_CASE( openFileRead, REGPATHS + EXECPATHS, path ) +BOOST_DATA_TEST_CASE(openFileRead, REGPATHS + EXECPATHS, path) { auto f = v->open(env, path, O_RDONLY); BOOST_REQUIRE(f); @@ -328,6 +333,4 @@ BOOST_DATA_TEST_CASE( openFileRead, REGPATHS + EXECPATHS, path ) f->close(); } - BOOST_AUTO_TEST_SUITE_END(); - diff --git a/unittests/mockDefs.cpp b/unittests/mockDefs.cpp index 1ecf11c..a257758 100644 --- a/unittests/mockDefs.cpp +++ b/unittests/mockDefs.cpp @@ -1,28 +1,26 @@ +#include "mockDefs.h" #include <boost/test/test_tools.hpp> #include <compileTimeFormatter.h> #include <definedDirs.h> -#include "mockDefs.h" using namespace AdHoc::literals; GitFS::Test::Service::Service() : IceTray::DryIce({ - "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()), - "--GitFS.testrepo.authkey=testauth", - "--GitFS.testrepo.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c930", + "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()), + "--GitFS.testrepo.authkey=testauth", + "--GitFS.testrepo.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c930", }) { } -GitFS::Test::Client::Client() : - s(getProxy<NetFS::ServicePrx>("Service")) +GitFS::Test::Client::Client() : s(getProxy<NetFS::ServicePrx>("Service")) { BOOST_TEST_REQUIRE(s); s->ice_ping(); } -GitFS::Test::VolumeClient::VolumeClient() : - v(s->connect("testrepo", "testauth")) +GitFS::Test::VolumeClient::VolumeClient() : v(s->connect("testrepo", "testauth")) { BOOST_TEST_REQUIRE(v); v->ice_ping(); @@ -32,4 +30,3 @@ GitFS::Test::VolumeClient::~VolumeClient() { v->disconnect(); } - diff --git a/unittests/mockDefs.h b/unittests/mockDefs.h index f6a6c99..750a256 100644 --- a/unittests/mockDefs.h +++ b/unittests/mockDefs.h @@ -1,31 +1,30 @@ #ifndef GITFS_TEST_MOCKDEFS_H #define GITFS_TEST_MOCKDEFS_H -#include <visibility.h> #include <dryice.h> #include <service.h> +#include <visibility.h> namespace GitFS::Test { class DLL_PUBLIC Service : public IceTray::DryIce { - public: - Service(); + public: + Service(); }; class DLL_PUBLIC Client : public IceTray::DryIceClient { - public: - Client(); + public: + Client(); - const NetFS::ServicePrxPtr s; + const NetFS::ServicePrxPtr s; }; class DLL_PUBLIC VolumeClient : public Client { - public: - VolumeClient(); - ~VolumeClient(); + public: + VolumeClient(); + ~VolumeClient(); - const NetFS::ReqEnv env; - const NetFS::VolumePrxPtr v; + const NetFS::ReqEnv env; + const NetFS::VolumePrxPtr v; }; } #endif - diff --git a/unittests/service.cpp b/unittests/service.cpp index 207aa15..b1bab5a 100644 --- a/unittests/service.cpp +++ b/unittests/service.cpp @@ -1,10 +1,10 @@ #define BOOST_TEST_MODULE GitFS_Service -#include <boost/test/unit_test.hpp> #include <boost/test/data/test_case.hpp> +#include <boost/test/unit_test.hpp> -#include <definedDirs.h> -#include <compileTimeFormatter.h> #include "mockDefs.h" +#include <compileTimeFormatter.h> +#include <definedDirs.h> using namespace GitFS; using namespace GitFS::Test; @@ -12,10 +12,8 @@ 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) +BOOST_DATA_TEST_CASE( + no_repos, btdata::make({"", "testrepo", "no repo"}) * btdata::make({"", "testauth", "badkey"}), repo, key) { IceTray::DryIce s; Client c; @@ -24,14 +22,12 @@ BOOST_DATA_TEST_CASE(no_repos, BOOST_CHECK_THROW(c.s->connect(repo, key), NetFS::ConfigError); } -BOOST_DATA_TEST_CASE(badauth, - btdata::make({ "", "testAuth", "badkey" }), - key) +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.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c930", + "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()), + "--GitFS.testrepo.authkey=testauth", + "--GitFS.testrepo.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c930", }); Client c; BOOST_CHECK_NO_THROW(c.s->ice_ping()); @@ -42,10 +38,10 @@ BOOST_DATA_TEST_CASE(badauth, 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.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c931", + "--GitFS.missing.gitdir=/not/here", + "--GitFS.missing.commit=7a0ccb40084c3ab31d9856e7f689c0514c28c930", + "--GitFS.testrepo.gitdir=%?"_fmt(rootDir.string()), + "--GitFS.testrepo.commitish=7a0ccb40084c3ab31d9856e7f689c0514c28c931", }); Client c; BOOST_CHECK_NO_THROW(c.s->ice_ping()); @@ -53,4 +49,3 @@ BOOST_AUTO_TEST_CASE(missing_repo) BOOST_CHECK_THROW(c.s->connect("missing", {}), NetFS::ConfigError); BOOST_CHECK_THROW(c.s->connect("testrepo", {}), NetFS::ConfigError); } - |