1 #include "clar_libgit2.h"
3 #include "repository.h"
5 #define REPO_PATH "testrepo2/.gitted"
6 #define REMOTE_ORIGIN "origin"
7 #define REMOTE_INSTEADOF_URL_FETCH "insteadof-url-fetch"
8 #define REMOTE_INSTEADOF_URL_PUSH "insteadof-url-push"
9 #define REMOTE_INSTEADOF_URL_BOTH "insteadof-url-both"
10 #define REMOTE_INSTEADOF_PUSHURL_FETCH "insteadof-pushurl-fetch"
11 #define REMOTE_INSTEADOF_PUSHURL_PUSH "insteadof-pushurl-push"
12 #define REMOTE_INSTEADOF_PUSHURL_BOTH "insteadof-pushurl-both"
14 static git_repository
*g_repo
;
15 static git_remote
*g_remote
;
17 void test_remote_insteadof__initialize(void)
23 void test_remote_insteadof__cleanup(void)
25 git_repository_free(g_repo
);
26 git_remote_free(g_remote
);
29 void test_remote_insteadof__not_applicable(void)
31 cl_git_pass(git_repository_open(&g_repo
, cl_fixture(REPO_PATH
)));
32 cl_git_pass(git_remote_lookup(&g_remote
, g_repo
, REMOTE_ORIGIN
));
35 git_remote_url(g_remote
),
36 "https://github.com/libgit2/false.git");
37 cl_assert_equal_p(git_remote_pushurl(g_remote
), NULL
);
40 void test_remote_insteadof__url_insteadof_fetch(void)
42 cl_git_pass(git_repository_open(&g_repo
, cl_fixture(REPO_PATH
)));
43 cl_git_pass(git_remote_lookup(&g_remote
, g_repo
, REMOTE_INSTEADOF_URL_FETCH
));
46 git_remote_url(g_remote
),
47 "http://github.com/url/fetch/libgit2");
48 cl_assert_equal_p(git_remote_pushurl(g_remote
), NULL
);
51 void test_remote_insteadof__url_insteadof_push(void)
53 cl_git_pass(git_repository_open(&g_repo
, cl_fixture(REPO_PATH
)));
54 cl_git_pass(git_remote_lookup(&g_remote
, g_repo
, REMOTE_INSTEADOF_URL_PUSH
));
57 git_remote_url(g_remote
),
58 "http://example.com/url/push/libgit2");
60 git_remote_pushurl(g_remote
),
61 "git@github.com:url/push/libgit2");
64 void test_remote_insteadof__url_insteadof_both(void)
66 cl_git_pass(git_repository_open(&g_repo
, cl_fixture(REPO_PATH
)));
67 cl_git_pass(git_remote_lookup(&g_remote
, g_repo
, REMOTE_INSTEADOF_URL_BOTH
));
70 git_remote_url(g_remote
),
71 "http://github.com/url/both/libgit2");
73 git_remote_pushurl(g_remote
),
74 "git@github.com:url/both/libgit2");
77 void test_remote_insteadof__pushurl_insteadof_fetch(void)
79 cl_git_pass(git_repository_open(&g_repo
, cl_fixture(REPO_PATH
)));
80 cl_git_pass(git_remote_lookup(&g_remote
, g_repo
, REMOTE_INSTEADOF_PUSHURL_FETCH
));
83 git_remote_url(g_remote
),
84 "http://github.com/url/fetch/libgit2");
86 git_remote_pushurl(g_remote
),
87 "http://github.com/url/fetch/libgit2-push");
90 void test_remote_insteadof__pushurl_insteadof_push(void)
92 cl_git_pass(git_repository_open(&g_repo
, cl_fixture(REPO_PATH
)));
93 cl_git_pass(git_remote_lookup(&g_remote
, g_repo
, REMOTE_INSTEADOF_PUSHURL_PUSH
));
96 git_remote_url(g_remote
),
97 "http://example.com/url/push/libgit2");
99 git_remote_pushurl(g_remote
),
100 "http://example.com/url/push/libgit2-push");
103 void test_remote_insteadof__pushurl_insteadof_both(void)
105 cl_git_pass(git_repository_open(&g_repo
, cl_fixture(REPO_PATH
)));
106 cl_git_pass(git_remote_lookup(&g_remote
, g_repo
, REMOTE_INSTEADOF_PUSHURL_BOTH
));
109 git_remote_url(g_remote
),
110 "http://github.com/url/both/libgit2");
112 git_remote_pushurl(g_remote
),
113 "http://github.com/url/both/libgit2-push");
116 void test_remote_insteadof__anonymous_remote_fetch(void)
118 cl_git_pass(git_repository_open(&g_repo
, cl_fixture(REPO_PATH
)));
119 cl_git_pass(git_remote_create_anonymous(&g_remote
, g_repo
,
120 "http://example.com/url/fetch/libgit2"));
123 git_remote_url(g_remote
),
124 "http://github.com/url/fetch/libgit2");
125 cl_assert_equal_p(git_remote_pushurl(g_remote
), NULL
);
128 void test_remote_insteadof__anonymous_remote_push(void)
130 cl_git_pass(git_repository_open(&g_repo
, cl_fixture(REPO_PATH
)));
131 cl_git_pass(git_remote_create_anonymous(&g_remote
, g_repo
,
132 "http://example.com/url/push/libgit2"));
135 git_remote_url(g_remote
),
136 "http://example.com/url/push/libgit2");
138 git_remote_pushurl(g_remote
),
139 "git@github.com:url/push/libgit2");
142 void test_remote_insteadof__anonymous_remote_both(void)
144 cl_git_pass(git_repository_open(&g_repo
, cl_fixture(REPO_PATH
)));
145 cl_git_pass(git_remote_create_anonymous(&g_remote
, g_repo
,
146 "http://example.com/url/both/libgit2"));
149 git_remote_url(g_remote
),
150 "http://github.com/url/both/libgit2");
152 git_remote_pushurl(g_remote
),
153 "git@github.com:url/both/libgit2");