4
4
#include "remote.h"
5
5
6
6
static git_remote * _remote ;
7
+ static git_remote * _https_remote ;
7
8
static git_repository * _repo ;
8
9
static const git_refspec * _refspec ;
9
10
@@ -12,6 +13,7 @@ void test_network_remote_remotes__initialize(void)
12
13
_repo = cl_git_sandbox_init ("testrepo.git" );
13
14
14
15
cl_git_pass (git_remote_lookup (& _remote , _repo , "test" ));
16
+ cl_git_pass (git_remote_lookup (& _https_remote , _repo , "https" ));
15
17
16
18
_refspec = git_remote_get_refspec (_remote , 0 );
17
19
cl_assert (_refspec != NULL );
@@ -22,6 +24,9 @@ void test_network_remote_remotes__cleanup(void)
22
24
git_remote_free (_remote );
23
25
_remote = NULL ;
24
26
27
+ git_remote_free (_https_remote );
28
+ _https_remote = NULL ;
29
+
25
30
cl_git_sandbox_cleanup ();
26
31
}
27
32
@@ -102,34 +107,42 @@ static int about_to_disconnect_callback_call_counter = 0;
102
107
static void connected_callback (git_remote * remote , void * payload )
103
108
{
104
109
connected_callback_call_counter ++ ;
105
- cl_assert_equal_p (remote , _remote );
110
+ cl_assert_equal_p (remote , _https_remote );
106
111
cl_assert_equal_s (payload , "payload" );
107
112
}
108
113
109
114
static void about_to_disconnect_callback (git_remote * remote , void * payload )
110
115
{
111
116
about_to_disconnect_callback_call_counter ++ ;
112
- cl_assert_equal_p (remote , _remote );
117
+ cl_assert_equal_p (remote , _https_remote );
113
118
cl_assert_equal_s (payload , "payload" );
114
119
}
115
120
116
121
void test_network_remote_remotes__connected_disconnected (void )
117
122
{
118
- git_remote_connect_options opts = GIT_REMOTE_CONNECT_OPTIONS_INIT ;
123
+ git_fetch_options opts = GIT_FETCH_OPTIONS_INIT ;
119
124
opts .callbacks .connected = connected_callback ;
120
125
opts .callbacks .about_to_disconnect = about_to_disconnect_callback ;
121
126
opts .callbacks .payload = "payload" ;
122
127
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 );
126
131
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 ));
128
133
129
134
cl_assert_equal_i (connected_callback_call_counter , 1 ); // check that called only once
130
135
cl_assert_equal_i (about_to_disconnect_callback_call_counter , 1 ); // check that called only once
131
136
}
132
137
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
+
133
146
#ifndef GIT_DEPRECATE_HARD
134
147
static int urlresolve_callback (git_buf * url_resolved , const char * url , int direction , void * payload )
135
148
{
@@ -446,7 +459,7 @@ void test_network_remote_remotes__list(void)
446
459
git_config * cfg ;
447
460
448
461
cl_git_pass (git_remote_list (& list , _repo ));
449
- cl_assert (list .count == 5 );
462
+ cl_assert (list .count == 6 );
450
463
git_strarray_dispose (& list );
451
464
452
465
cl_git_pass (git_repository_config (& cfg , _repo ));
@@ -458,7 +471,7 @@ void test_network_remote_remotes__list(void)
458
471
cl_git_pass (git_config_set_string (cfg , "remote.no-remote-url.pushurl" , "http://example.com" ));
459
472
460
473
cl_git_pass (git_remote_list (& list , _repo ));
461
- cl_assert (list .count == 7 );
474
+ cl_assert (list .count == 8 );
462
475
git_strarray_dispose (& list );
463
476
464
477
git_config_free (cfg );
0 commit comments