3void test_git_commit_no_git_no_fail(
void **state) {
4 will_return(__wrap_CreateProcess,
false);
5 assert_true(git_commit(
nullptr,
nullptr));
8void test_git_commit_no_dot_git_wgetcwd_fail(
void **state) {
9 will_return(__wrap_CreateProcess,
true);
10 will_return(__wrap_GetExitCodeProcess, 0);
11 will_return(__wrap_GetExitCodeProcess,
true);
12 will_return_always(__wrap_WaitForSingleObject, 0);
13 will_return_always(__wrap_CloseHandle,
true);
14 will_return(__wrap_GetFileAttributes, INVALID_FILE_ATTRIBUTES);
15 will_return(__wrap__wgetcwd, 0);
16 assert_false(git_commit(L
"output-dir",
nullptr));
19void test_git_commit_no_dot_git_wchdir_fail(
void **state) {
20 will_return(__wrap_CreateProcess,
true);
21 will_return(__wrap_GetExitCodeProcess, 0);
22 will_return(__wrap_GetExitCodeProcess,
true);
23 will_return_always(__wrap_WaitForSingleObject, 0);
24 will_return_always(__wrap_CloseHandle,
true);
25 will_return(__wrap_GetFileAttributes, INVALID_FILE_ATTRIBUTES);
26 will_return(__wrap__wgetcwd, L
"");
27 will_return(__wrap__wchdir, 1);
28 assert_false(git_commit(L
"output-dir",
nullptr));
31void test_git_commit_no_dot_git_wchdir_fail_2(
void **state) {
32 will_return(__wrap_CreateProcess,
true);
33 will_return(__wrap_GetExitCodeProcess, 0);
34 will_return(__wrap_GetExitCodeProcess,
true);
35 will_return_always(__wrap_WaitForSingleObject, 0);
36 will_return_always(__wrap_CloseHandle,
true);
37 will_return(__wrap_GetFileAttributes, INVALID_FILE_ATTRIBUTES);
38 will_return(__wrap__wgetcwd, L
"");
39 will_return(__wrap__wchdir, 0);
40 will_return(__wrap_CreateProcess,
true);
41 will_return(__wrap_GetExitCodeProcess, 0);
42 will_return(__wrap_GetExitCodeProcess,
true);
43 will_return(__wrap__wchdir, 1);
44 assert_false(git_commit(L
"output-dir",
nullptr));
47void test_git_commit_no_dot_git_CreateProcess_fail(
void **state) {
48 will_return(__wrap_CreateProcess,
true);
49 will_return(__wrap_GetExitCodeProcess, 0);
50 will_return(__wrap_GetExitCodeProcess,
true);
51 will_return_always(__wrap_WaitForSingleObject, 0);
52 will_return_always(__wrap_CloseHandle,
true);
53 will_return(__wrap_GetFileAttributes, INVALID_FILE_ATTRIBUTES);
54 will_return(__wrap__wgetcwd, L
"");
55 will_return(__wrap__wchdir, 0);
56 will_return(__wrap_CreateProcess,
false);
57 assert_false(git_commit(L
"output-dir",
nullptr));
60void test_git_commit_no_dot_git_GetExitCodeProcess_fail(
void **state) {
61 will_return(__wrap_CreateProcess,
true);
62 will_return(__wrap_GetExitCodeProcess, 0);
63 will_return(__wrap_GetExitCodeProcess,
true);
64 will_return_always(__wrap_WaitForSingleObject, 0);
65 will_return_always(__wrap_CloseHandle,
true);
66 will_return(__wrap_GetFileAttributes, INVALID_FILE_ATTRIBUTES);
67 will_return(__wrap__wgetcwd, L
"");
68 will_return(__wrap__wchdir, 0);
69 will_return(__wrap_CreateProcess,
true);
70 will_return(__wrap_GetExitCodeProcess, -1);
71 will_return(__wrap_GetExitCodeProcess,
false);
72 assert_false(git_commit(L
"output-dir",
nullptr));
75void test_git_commit_add_fail(
void **state) {
76 will_return(__wrap_CreateProcess,
true);
77 will_return(__wrap_GetExitCodeProcess, 0);
78 will_return(__wrap_GetExitCodeProcess,
true);
79 will_return_always(__wrap_WaitForSingleObject, 0);
80 will_return_always(__wrap_CloseHandle,
true);
81 will_return(__wrap_GetFileAttributes, FILE_ATTRIBUTE_DIRECTORY);
82 will_return(__wrap_CreateProcess,
false);
83 assert_false(git_commit(L
"output-dir",
nullptr));
86void test_git_commit_GetTimeFormat_fail(
void **state) {
87 will_return(__wrap_CreateProcess,
true);
88 will_return(__wrap_GetExitCodeProcess, 0);
89 will_return(__wrap_GetExitCodeProcess,
true);
90 will_return_always(__wrap_WaitForSingleObject, 0);
91 will_return_always(__wrap_CloseHandle,
true);
92 will_return(__wrap_GetFileAttributes, FILE_ATTRIBUTE_DIRECTORY);
93 will_return(__wrap_CreateProcess,
true);
94 will_return(__wrap_GetExitCodeProcess, 0);
95 will_return(__wrap_GetExitCodeProcess,
true);
96 will_return(__wrap_GetTimeFormat, 0);
97 assert_false(git_commit(L
"output-dir",
nullptr));
99 will_return(__wrap_CreateProcess,
true);
100 will_return(__wrap_GetExitCodeProcess, 0);
101 will_return(__wrap_GetExitCodeProcess,
true);
102 will_return(__wrap_GetFileAttributes, FILE_ATTRIBUTE_DIRECTORY);
103 will_return(__wrap_CreateProcess,
true);
104 will_return(__wrap_GetExitCodeProcess, 0);
105 will_return(__wrap_GetExitCodeProcess,
true);
106 will_return(__wrap_GetTimeFormat, 10);
107 will_return(__wrap_GetTimeFormat, 0);
108 assert_false(git_commit(L
"output-dir",
nullptr));
111void test_git_commit_GetDateFormat_fail(
void **state) {
112 will_return(__wrap_CreateProcess,
true);
113 will_return(__wrap_GetExitCodeProcess, 0);
114 will_return(__wrap_GetExitCodeProcess,
true);
115 will_return_always(__wrap_WaitForSingleObject, 0);
116 will_return_always(__wrap_CloseHandle,
true);
117 will_return(__wrap_GetFileAttributes, FILE_ATTRIBUTE_DIRECTORY);
118 will_return(__wrap_CreateProcess,
true);
119 will_return(__wrap_GetExitCodeProcess, 0);
120 will_return(__wrap_GetExitCodeProcess,
true);
121 will_return_always(__wrap_GetTimeFormat, 10);
122 will_return(__wrap_GetDateFormat, 0);
123 assert_false(git_commit(L
"output-dir",
nullptr));
125 will_return(__wrap_CreateProcess,
true);
126 will_return(__wrap_GetExitCodeProcess, 0);
127 will_return(__wrap_GetExitCodeProcess,
true);
128 will_return(__wrap_GetFileAttributes, FILE_ATTRIBUTE_DIRECTORY);
129 will_return(__wrap_CreateProcess,
true);
130 will_return(__wrap_GetExitCodeProcess, 0);
131 will_return(__wrap_GetExitCodeProcess,
true);
132 will_return(__wrap_GetDateFormat, 10);
133 will_return(__wrap_GetDateFormat, 0);
134 assert_false(git_commit(L
"output-dir",
nullptr));
137void test_git_commit_fail(
void **state) {
138 will_return(__wrap_CreateProcess,
true);
139 will_return(__wrap_GetExitCodeProcess, 0);
140 will_return(__wrap_GetExitCodeProcess,
true);
141 will_return_always(__wrap_WaitForSingleObject, 0);
142 will_return_always(__wrap_CloseHandle,
true);
143 will_return(__wrap_GetFileAttributes, FILE_ATTRIBUTE_DIRECTORY);
144 will_return(__wrap_CreateProcess,
true);
145 will_return(__wrap_GetExitCodeProcess, 0);
146 will_return(__wrap_GetExitCodeProcess,
true);
147 will_return(__wrap_GetTimeFormat, 10);
148 will_return(__wrap_GetTimeFormat, 10);
149 will_return(__wrap_GetDateFormat, 10);
150 will_return(__wrap_GetDateFormat, 10);
151 will_return(__wrap_CreateProcess,
false);
152 assert_false(git_commit(L
"output-dir",
nullptr));
155void test_git_commit_deploy_key_wfullpath_fail(
void **state) {
156 will_return(__wrap_CreateProcess,
true);
157 will_return(__wrap_GetExitCodeProcess, 0);
158 will_return(__wrap_GetExitCodeProcess,
true);
159 will_return_always(__wrap_WaitForSingleObject, 0);
160 will_return_always(__wrap_CloseHandle,
true);
161 will_return(__wrap_GetFileAttributes, FILE_ATTRIBUTE_DIRECTORY);
162 will_return(__wrap_CreateProcess,
true);
163 will_return(__wrap_GetExitCodeProcess, 0);
164 will_return(__wrap_GetExitCodeProcess,
true);
165 will_return(__wrap_GetTimeFormat, 10);
166 will_return(__wrap_GetTimeFormat, 10);
167 will_return(__wrap_GetDateFormat, 10);
168 will_return(__wrap_GetDateFormat, 10);
169 will_return(__wrap_CreateProcess,
true);
170 will_return(__wrap_GetExitCodeProcess, 0);
171 will_return(__wrap_GetExitCodeProcess,
true);
172 will_return(__wrap__wfullpath, 0);
173 will_return(__wrap__wfullpath, 0);
174 assert_false(git_commit(L
"output-dir", L
"key"));
177void test_git_commit_deploy_key_config_fail(
void **state) {
178 will_return(__wrap_CreateProcess,
true);
179 will_return(__wrap_GetExitCodeProcess, 0);
180 will_return(__wrap_GetExitCodeProcess,
true);
181 will_return_always(__wrap_WaitForSingleObject, 0);
182 will_return_always(__wrap_CloseHandle,
true);
183 will_return(__wrap_GetFileAttributes, FILE_ATTRIBUTE_DIRECTORY);
184 will_return(__wrap_CreateProcess,
true);
185 will_return(__wrap_GetExitCodeProcess, 0);
186 will_return(__wrap_GetExitCodeProcess,
true);
187 will_return(__wrap_GetTimeFormat, 10);
188 will_return(__wrap_GetTimeFormat, 10);
189 will_return(__wrap_GetDateFormat, 10);
190 will_return(__wrap_GetDateFormat, 10);
191 will_return(__wrap_CreateProcess,
true);
192 will_return(__wrap_GetExitCodeProcess, 0);
193 will_return(__wrap_GetExitCodeProcess,
true);
194 will_return(__wrap__wfullpath, L
"");
195 will_return(__wrap__wfullpath, L
"");
196 will_return(__wrap_CreateProcess,
false);
197 assert_false(git_commit(L
"output-dir", L
"key"));
200void test_git_commit_deploy_key_push_fail(
void **state) {
201 will_return(__wrap_CreateProcess,
true);
202 will_return(__wrap_GetExitCodeProcess, 0);
203 will_return(__wrap_GetExitCodeProcess,
true);
204 will_return_always(__wrap_WaitForSingleObject, 0);
205 will_return_always(__wrap_CloseHandle,
true);
206 will_return(__wrap_GetFileAttributes, FILE_ATTRIBUTE_DIRECTORY);
207 will_return(__wrap_CreateProcess,
true);
208 will_return(__wrap_GetExitCodeProcess, 0);
209 will_return(__wrap_GetExitCodeProcess,
true);
210 will_return(__wrap_GetTimeFormat, 10);
211 will_return(__wrap_GetTimeFormat, 10);
212 will_return(__wrap_GetDateFormat, 10);
213 will_return(__wrap_GetDateFormat, 10);
214 will_return(__wrap_CreateProcess,
true);
215 will_return(__wrap_GetExitCodeProcess, 0);
216 will_return(__wrap_GetExitCodeProcess,
true);
217 will_return(__wrap__wfullpath, L
"");
218 will_return(__wrap__wfullpath, L
"");
219 will_return(__wrap_CreateProcess,
true);
220 will_return(__wrap_GetExitCodeProcess, 0);
221 will_return(__wrap_GetExitCodeProcess,
true);
222 will_return(__wrap_get_git_branch, L
"master");
223 will_return(__wrap_CreateProcess,
false);
224 assert_false(git_commit(L
"output-dir", L
"key"));
227void test_git_commit_deploy_key(
void **state) {
228 will_return(__wrap_CreateProcess,
true);
229 will_return(__wrap_GetExitCodeProcess, 0);
230 will_return(__wrap_GetExitCodeProcess,
true);
231 will_return_always(__wrap_WaitForSingleObject, 0);
232 will_return_always(__wrap_CloseHandle,
true);
233 will_return(__wrap_GetFileAttributes, FILE_ATTRIBUTE_DIRECTORY);
234 will_return(__wrap_CreateProcess,
true);
235 will_return(__wrap_GetExitCodeProcess, 0);
236 will_return(__wrap_GetExitCodeProcess,
true);
237 will_return(__wrap_GetTimeFormat, 10);
238 will_return(__wrap_GetTimeFormat, 10);
239 will_return(__wrap_GetDateFormat, 10);
240 will_return(__wrap_GetDateFormat, 10);
241 will_return(__wrap_CreateProcess,
true);
242 will_return(__wrap_GetExitCodeProcess, 0);
243 will_return(__wrap_GetExitCodeProcess,
true);
244 will_return(__wrap__wfullpath, L
"");
245 will_return(__wrap__wfullpath, L
"");
246 will_return(__wrap_CreateProcess,
true);
247 will_return(__wrap_GetExitCodeProcess, 0);
248 will_return(__wrap_GetExitCodeProcess,
true);
249 will_return(__wrap_get_git_branch, L
"master");
250 will_return(__wrap_CreateProcess,
true);
251 will_return(__wrap_GetExitCodeProcess, 0);
252 will_return(__wrap_GetExitCodeProcess,
true);
253 assert_true(git_commit(L
"output-dir", L
"key"));
256const struct CMUnitTest git_commit_tests[] = {
257 cmocka_unit_test(test_git_commit_GetDateFormat_fail),
258 cmocka_unit_test(test_git_commit_GetTimeFormat_fail),
259 cmocka_unit_test(test_git_commit_add_fail),
260 cmocka_unit_test(test_git_commit_deploy_key),
261 cmocka_unit_test(test_git_commit_deploy_key_config_fail),
262 cmocka_unit_test(test_git_commit_deploy_key_push_fail),
263 cmocka_unit_test(test_git_commit_deploy_key_wfullpath_fail),
264 cmocka_unit_test(test_git_commit_fail),
265 cmocka_unit_test(test_git_commit_no_dot_git_CreateProcess_fail),
266 cmocka_unit_test(test_git_commit_no_dot_git_GetExitCodeProcess_fail),
267 cmocka_unit_test(test_git_commit_no_dot_git_wchdir_fail),
268 cmocka_unit_test(test_git_commit_no_dot_git_wchdir_fail_2),
269 cmocka_unit_test(test_git_commit_no_dot_git_wgetcwd_fail),
270 cmocka_unit_test(test_git_commit_no_git_no_fail),
273int main(
int argc,
char *argv[]) {
274 return cmocka_run_group_tests(git_commit_tests,
nullptr,
nullptr);