10000 fix tests. add https_remote to github repo, because unauthenticated a… · libgit2/libgit2@217dbc8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 217dbc8

Browse files
committed
fix tests. add https_remote to github repo, because unauthenticated access to github over port 9418 is anymore supported
1 parent 1a43ca9 commit 217dbc8

File tree

3 files changed

+27
-9
lines changed

3 files changed

+27
-9
lines changed

tests/libgit2/network/remote/remotes.c

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include "remote.h"
55

66
static git_remote *_remote;
7+
static git_remote *_https_remote;
78
static git_repository *_repo;
89
static const git_refspec *_refspec;
910

@@ -12,6 +13,7 @@ void test_network_remote_remotes__initialize(void)
1213
_repo = cl_git_sandbox_init("testrepo.git");
1314

1415
cl_git_pass(git_remote_lookup(&_remote, _repo, "test"));
16+
cl_git_pass(git_remote_lookup(&_https_remote, _repo, "https"));
1517

1618
_refspec = git_remote_get_refspec(_remote, 0);
1719
cl_assert(_refspec != NULL);
@@ -22,6 +24,9 @@ void test_network_remote_remotes__cleanup(void)
2224
git_remote_free(_remote);
2325
_remote = NULL;
2426

27+
git_remote_free(_https_remote);
28+
_https_remote = NULL;
29+
2530
cl_git_sandbox_cleanup();
2631
}
2732

@@ -102,34 +107,42 @@ static int about_to_disconnect_callback_call_counter = 0;
102107
static void connected_callback(git_remote *remote, void *payload)
103108
{
104109
connected_callback_call_counter ++;
105-
cl_assert_equal_p(remote, _remote);
110+
cl_assert_equal_p(remote, _https_remote);
106111
cl_assert_equal_s(payload, "payload");
107112
}
108113

109114
static void about_to_disconnect_callback(git_remote *remote, void *payload)
110115
{
111116
about_to_disconnect_callback_call_counter ++;
112-
cl_assert_equal_p(remote, _remote);
117+
cl_assert_equal_p(remote, _https_remote);
113118
cl_assert_equal_s(payload, "payload");
114119
}
115120

116121
void test_network_remote_remotes__connected_disconnected(void)
117122
{
118-
git_remote_connect_options opts = GIT_REMOTE_CONNECT_OPTIONS_INIT;
123+
git_fetch_options opts = GIT_FETCH_OPTIONS_INIT;
119124
opts.callbacks.connected = connected_callback;
120125
opts.callbacks.about_to_disconnect = about_to_disconnect_callback;
121126
opts.callbacks.payload = "payload";
122127

123-
cl_assert_equal_s(git_remote_name(_remote), "test");
124-
cl_assert_equal_s(git_remote_url(_remote), "git://github.com/libgit2/libgit2");
125-
cl_assert(git_remote_pushurl(_remote) == NULL);
128+
cl_assert_equal_s(git_remote_name(_https_remote), "https");
129+
cl_assert_equal_s(git_remote_url(_https_remote), "https://github.com/libgit2/libgit2");
130+
cl_assert(git_remote_pushurl(_https_remote) == NULL);
126131

127-
cl_git_pass(git_remote_connect_ext(_remote, GIT_DIRECTION_FETCH, &opts));
132+
cl_git_pass(git_remote_fetch(_https_remote, NULL, &opts, NULL));
128133

129134
cl_assert_equal_i(connected_callback_call_counter, 1); // check that called only once
130135
cl_assert_equal_i(about_to_disconnect_callback_call_counter, 1); // check that called only once
131136
}
132137

138+
void test_network_remote_remotes__connected_disconnected_no_call(void)
139+
{
140+
cl_git_pass(git_remote_fetch(_https_remote, NULL, NULL, NULL));
141+
142+
cl_assert_equal_i(connected_callback_call_counter, 1); // check that called only once
143+
cl_assert_equal_i(about_to_disconnect_callback_call_counter, 1); // check that called only once
144+
}
145+
133146
#ifndef GIT_DEPRECATE_HARD
134147
static int urlresolve_callback(git_buf *url_resolved, const char *url, int direction, void *payload)
135148
{
@@ -446,7 +459,7 @@ void test_network_remote_remotes__list(void)
446459
git_config *cfg;
447460

448461
cl_git_pass(git_remote_list(&list, _repo));
449-
cl_assert(list.count == 5);
462+
cl_assert(list.count == 6);
450463
git_strarray_dispose(&list);
451464

452465
cl_git_pass(git_repository_config(&cfg, _repo));
@@ -458,7 +471,7 @@ void test_network_remote_remotes__list(void)
458471
cl_git_pass(git_config_set_string(cfg, "remote.no-remote-url.pushurl", "http://example.com"));
459472

460473
cl_git_pass(git_remote_list(&list, _repo));
461-
cl_assert(list.count == 7);
474+
cl_assert(list.count == 8);
462475
git_strarray_dispose(&list);
463476

464477
git_config_free(cfg);

tests/libgit2/submodule/update.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,11 @@ static void about_to_disconnect_callback(git_remote *remote, void *payload)
483483
void test_submodule_update__abort_update(void)
484484
{
485485
git_submodule *sm;
486+
char* payload = "payload";
486487
git_submodule_update_options update_options = GIT_SUBMODULE_UPDATE_OPTIONS_INIT;
487488
update_options.fetch_opts.callbacks.connected = connected_callback;
488489
update_options.fetch_opts.callbacks.about_to_disconnect = about_to_disconnect_callback;
490+
update_options.fetch_opts.callbacks.payload = payload;
489491
unsigned int submodule_status;
490492

491493
g_repo = setup_fixture_submodule_simple();

tests/resources/testrepo.git/config

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,6 @@
3838
[branch "mergeandremoteless"]
3939
remote =
4040
merge =
41+
[remote "https"]
42+
url = https://github.com/libgit2/libgit2
43+
fetch = +refs/heads/*:refs/remotes/https/*

0 commit comments

Comments
 (0)
0