summaryrefslogtreecommitdiff
path: root/tests/clone
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2013-12-23 11:12:31 +0000
committerCarlos Martín Nieto <cmn@dwim.me>2014-05-28 15:40:22 +0200
commit121b26738e6a5e6eadeb2a2bc666956ae21cb92b (patch)
tree9f97b747cf21db85b255ae19b5b86ad768a7ba04 /tests/clone
parenta0b5f7854c2302105e1029933df5d94a765cb89f (diff)
downloadlibgit2-121b26738e6a5e6eadeb2a2bc666956ae21cb92b.tar.gz
clone: add flags to override whether to perform a local clone
Diffstat (limited to 'tests/clone')
-rw-r--r--tests/clone/local.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/tests/clone/local.c b/tests/clone/local.c
new file mode 100644
index 000000000..478bbb673
--- /dev/null
+++ b/tests/clone/local.c
@@ -0,0 +1,29 @@
+#include "clar_libgit2.h"
+
+#include "git2/clone.h"
+#include "clone.h"
+#include "buffer.h"
+
+void assert_clone(const char *path, git_clone_local_t opt, int val)
+{
+ cl_assert_equal_i(val, git_clone__should_clone_local(path, opt));
+}
+
+void test_clone_local__should_clone_local(void)
+{
+ git_buf buf = GIT_BUF_INIT;
+ const char *path;
+
+ /* we use a fixture path because it needs to exist for us to want to clone */
+
+ cl_git_pass(git_buf_printf(&buf, "file://%s", cl_fixture("testrepo.git")));
+ cl_assert_equal_i(false, git_clone__should_clone_local(buf.ptr, GIT_CLONE_LOCAL_AUTO));
+ cl_assert_equal_i(true, git_clone__should_clone_local(buf.ptr, GIT_CLONE_LOCAL));
+ cl_assert_equal_i(false, git_clone__should_clone_local(buf.ptr, GIT_CLONE_NO_LOCAL));
+ git_buf_free(&buf);
+
+ path = cl_fixture("testrepo.git");
+ cl_assert_equal_i(true, git_clone__should_clone_local(path, GIT_CLONE_LOCAL_AUTO));
+ cl_assert_equal_i(true, git_clone__should_clone_local(path, GIT_CLONE_LOCAL));
+ cl_assert_equal_i(false, git_clone__should_clone_local(path, GIT_CLONE_NO_LOCAL));
+}