summaryrefslogtreecommitdiff
path: root/tests/network/remote/remotes.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/network/remote/remotes.c')
-rw-r--r--tests/network/remote/remotes.c41
1 files changed, 21 insertions, 20 deletions
diff --git a/tests/network/remote/remotes.c b/tests/network/remote/remotes.c
index ed6a89075..79c4f39fa 100644
--- a/tests/network/remote/remotes.c
+++ b/tests/network/remote/remotes.c
@@ -1,6 +1,5 @@
#include "clar_libgit2.h"
#include "config/config_helpers.h"
-#include "buffer.h"
#include "refspec.h"
#include "remote.h"
@@ -28,7 +27,7 @@ void test_network_remote_remotes__cleanup(void)
void test_network_remote_remotes__parsing(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
git_remote *_remote2 = NULL;
cl_assert_equal_s(git_remote_name(_remote), "test");
@@ -53,7 +52,7 @@ void test_network_remote_remotes__parsing(void)
cl_assert_equal_s(url.ptr, "git://github.com/libgit2/pushlibgit2");
git_remote_free(_remote2);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
static int remote_ready_callback(git_remote *remote, int direction, void *payload)
@@ -79,7 +78,7 @@ static int remote_ready_callback(git_remote *remote, int direction, void *payloa
void test_network_remote_remotes__remote_ready(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
callbacks.remote_ready = remote_ready_callback;
@@ -95,29 +94,31 @@ void test_network_remote_remotes__remote_ready(void)
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_PUSH, &callbacks));
cl_assert_equal_s(url.ptr, "push_url");
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
#ifndef GIT_DEPRECATE_HARD
static int urlresolve_callback(git_buf *url_resolved, const char *url, int direction, void *payload)
{
+ int error = -1;
+
cl_assert(strcmp(url, "git://github.com/libgit2/libgit2") == 0);
cl_assert(strcmp(payload, "payload") == 0);
cl_assert(url_resolved->size == 0);
if (direction == GIT_DIRECTION_PUSH)
- git_buf_sets(url_resolved, "pushresolve");
+ error = git_buf_set(url_resolved, "pushresolve", strlen("pushresolve") + 1);
if (direction == GIT_DIRECTION_FETCH)
- git_buf_sets(url_resolved, "fetchresolve");
+ error = git_buf_set(url_resolved, "fetchresolve", strlen("fetchresolve") + 1);
- return GIT_OK;
+ return error;
}
#endif
void test_network_remote_remotes__urlresolve(void)
{
#ifndef GIT_DEPRECATE_HARD
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
callbacks.resolve_url = urlresolve_callback;
@@ -133,7 +134,7 @@ void test_network_remote_remotes__urlresolve(void)
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_PUSH, &callbacks));
cl_assert_equal_s(url.ptr, "pushresolve");
- git_buf_dispose(&url);
+ git_str_dispose(&url);
#endif
}
@@ -151,7 +152,7 @@ static int urlresolve_passthrough_callback(git_buf *url_resolved, const char *ur
void test_network_remote_remotes__urlresolve_passthrough(void)
{
#ifndef GIT_DEPRECATE_HARD
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
const char *orig_url = "git://github.com/libgit2/libgit2";
git_remote_callbacks callbacks = GIT_REMOTE_CALLBACKS_INIT;
@@ -167,13 +168,13 @@ void test_network_remote_remotes__urlresolve_passthrough(void)
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_PUSH, &callbacks));
cl_assert_equal_s(url.ptr, orig_url);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
#endif
}
void test_network_remote_remotes__instance_url(void)
{
- git_buf url = GIT_BUF_INIT;
+ git_str url = GIT_STR_INIT;
const char *orig_url = "git://github.com/libgit2/libgit2";
cl_assert_equal_s(git_remote_name(_remote), "test");
@@ -181,11 +182,11 @@ void test_network_remote_remotes__instance_url(void)
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_FETCH, NULL));
cl_assert_equal_s(url.ptr, orig_url);
- git_buf_clear(&url);
+ git_str_clear(&url);
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_PUSH, NULL));
cl_assert_equal_s(url.ptr, orig_url);
- git_buf_clear(&url);
+ git_str_clear(&url);
/* Setting the instance url updates the fetch and push URLs */
git_remote_set_instance_url(_remote, "https://github.com/new/remote/url");
@@ -194,11 +195,11 @@ void test_network_remote_remotes__instance_url(void)
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_FETCH, NULL));
cl_assert_equal_s(url.ptr, "https://github.com/new/remote/url");
- git_buf_clear(&url);
+ git_str_clear(&url);
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_PUSH, NULL));
cl_assert_equal_s(url.ptr, "https://github.com/new/remote/url");
- git_buf_clear(&url);
+ git_str_clear(&url);
/* Setting the instance push url updates only the push URL */
git_remote_set_instance_pushurl(_remote, "https://github.com/new/push/url");
@@ -207,13 +208,13 @@ void test_network_remote_remotes__instance_url(void)
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_FETCH, NULL));
cl_assert_equal_s(url.ptr, "https://github.com/new/remote/url");
- git_buf_clear(&url);
+ git_str_clear(&url);
cl_git_pass(git_remote__urlfordirection(&url, _remote, GIT_DIRECTION_PUSH, NULL));
cl_assert_equal_s(url.ptr, "https://github.com/new/push/url");
- git_buf_clear(&url);
+ git_str_clear(&url);
- git_buf_dispose(&url);
+ git_str_dispose(&url);
}
void test_network_remote_remotes__pushurl(void)