Skip to content

Commit f8fc987

Browse files
committed
tests: git_remote_create_detached
1 parent 4e0da45 commit f8fc987

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/remote/create.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ void test_remote_create__named(void)
7676

7777
cl_assert_equal_s(git_remote_name(remote), "valid-name");
7878
cl_assert_equal_s(git_remote_url(remote), TEST_URL);
79+
cl_assert_equal_p(git_remote_owner(remote), _repo);
7980

8081
cl_git_pass(git_repository_config_snapshot(&cfg, _repo));
8182

@@ -119,6 +120,10 @@ void test_remote_create__with_fetchspec(void)
119120
size_t section_count = cl_git_config_sections_count(_config, "remote.");
120121

121122
cl_git_pass(git_remote_create_with_fetchspec(&remote, _repo, "test-new", "git://github.com/libgit2/libgit2", "+refs/*:refs/*"));
123+
cl_assert_equal_s(git_remote_name(remote), "test-new");
124+
cl_assert_equal_s(git_remote_url(remote), "git://github.com/libgit2/libgit2");
125+
cl_assert_equal_p(git_remote_owner(remote), _repo);
126+
122127
cl_git_pass(git_remote_get_fetch_refspecs(&array, remote));
123128
cl_assert_equal_s("+refs/*:refs/*", array.strings[0]);
124129
cl_assert_equal_i(1, array.count);
@@ -162,6 +167,7 @@ void test_remote_create__anonymous(void)
162167
cl_git_pass(git_remote_create_anonymous(&remote, _repo, TEST_URL));
163168
cl_assert_equal_s(git_remote_name(remote), NULL);
164169
cl_assert_equal_s(git_remote_url(remote), TEST_URL);
170+
cl_assert_equal_p(git_remote_owner(remote), _repo);
165171

166172
cl_git_pass(git_remote_get_fetch_refspecs(&array, remote));
167173
cl_assert_equal_i(0, array.count);
@@ -175,3 +181,27 @@ void test_remote_create__anonymous_invalid_url(void)
175181
{
176182
cl_git_assert_cannot_create_remote(GIT_EINVALIDSPEC, git_remote_create_anonymous(&r, _repo, ""));
177183
}
184+
185+
void test_remote_create__detached(void)
186+
{
187+
git_remote *remote;
188+
git_strarray array;
189+
size_t section_count = cl_git_config_sections_count(_config, "remote.");
190+
191+
cl_git_pass(git_remote_create_detached(&remote, TEST_URL));
192+
cl_assert_equal_s(git_remote_name(remote), NULL);
193+
cl_assert_equal_s(git_remote_url(remote), TEST_URL);
194+
cl_assert_equal_p(git_remote_owner(remote), NULL);
195+
196+
cl_git_pass(git_remote_get_fetch_refspecs(&array, remote));
197+
cl_assert_equal_i(0, array.count);
198+
cl_assert_equal_i(section_count, cl_git_config_sections_count(_config, "remote."));
199+
200+
git_strarray_free(&array);
201+
git_remote_free(remote);
202+
}
203+
204+
void test_remote_create__detached_invalid_url(void)
205+
{
206+
cl_git_assert_cannot_create_remote(GIT_EINVALIDSPEC, git_remote_create_detached(&r, ""));
207+
}

0 commit comments

Comments
 (0)