summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gentoobrowse-api/service/utils/git.cpp3
-rw-r--r--gentoobrowse-api/service/utils/git.h2
-rw-r--r--gentoobrowse-api/unittests/Jamfile.jam8
-rw-r--r--gentoobrowse-api/unittests/testUtils.cpp23
4 files changed, 34 insertions, 2 deletions
diff --git a/gentoobrowse-api/service/utils/git.cpp b/gentoobrowse-api/service/utils/git.cpp
index 1dd3653..bbd69a3 100644
--- a/gentoobrowse-api/service/utils/git.cpp
+++ b/gentoobrowse-api/service/utils/git.cpp
@@ -10,8 +10,9 @@ namespace Gentoo {
throwError(void * const func, int err)
{
const git_error * e = giterr_last();
- fprintf(stderr, "func %p\n", func);
char ** fn = backtrace_symbols(&func, 1);
+ assert(fn);
+ assert(*fn);
throw ::Gentoo::GitError(*fn, err, e->klass, e->message);
}
diff --git a/gentoobrowse-api/service/utils/git.h b/gentoobrowse-api/service/utils/git.h
index 7df0172..6900435 100644
--- a/gentoobrowse-api/service/utils/git.h
+++ b/gentoobrowse-api/service/utils/git.h
@@ -11,7 +11,7 @@ namespace Gentoo {
gitSafe(int (*func)(P...), A ... p)
{
if (int _giterror = func(p...) < 0) {
- throwError(&func, _giterror);
+ throwError((void * const)func, _giterror);
}
}
diff --git a/gentoobrowse-api/unittests/Jamfile.jam b/gentoobrowse-api/unittests/Jamfile.jam
index 558d7d9..9f60eb4 100644
--- a/gentoobrowse-api/unittests/Jamfile.jam
+++ b/gentoobrowse-api/unittests/Jamfile.jam
@@ -47,6 +47,14 @@ lib testCommon :
;
run
+ testUtils.cpp ../service/utils/git.cpp
+ : : :
+ <define>BOOST_TEST_DYN_LINK
+ <library>testCommon
+ <library>git2
+ : testUtils ;
+
+run
testDepend.cpp ../service/depend.cpp
: : :
<define>BOOST_TEST_DYN_LINK
diff --git a/gentoobrowse-api/unittests/testUtils.cpp b/gentoobrowse-api/unittests/testUtils.cpp
new file mode 100644
index 0000000..e89f0fb
--- /dev/null
+++ b/gentoobrowse-api/unittests/testUtils.cpp
@@ -0,0 +1,23 @@
+#define BOOST_TEST_MODULE TestDepend
+#include <boost/test/unit_test.hpp>
+
+#include <utils/git.h>
+#include <maintenance.h>
+
+using namespace Gentoo::Utils::Git;
+
+BOOST_AUTO_TEST_CASE( gitErrorMessage )
+{
+ try {
+ gitSafeGet(git_repository_open_ext, git_repository_free, "/", 0, nullptr);
+ }
+ catch (const Gentoo::GitError & ge) {
+ BOOST_TEST_CONTEXT(ge.what()) {
+ BOOST_REQUIRE_EQUAL(ge.errorCode, 1);
+ BOOST_REQUIRE_EQUAL(ge.errorClass, 6);
+ BOOST_REQUIRE(ge.operation.find("git_repository_open_ext") + 1);
+ BOOST_REQUIRE(ge.message.find("repository") + 1);
+ }
+ }
+}
+