Lines Matching refs:storage
11 #include "mail-storage-service.h"
12 #include "mail-storage-private.h"
21 static void test_deinit_storage(struct mail_storage *storage)
23 mail_storage_clear_error(storage);
24 if (array_is_created(&storage->error_stack)) {
25 mail_storage_clear_error(storage);
26 i_assert(array_count(&storage->error_stack) == 0);
27 array_free(&storage->error_stack);
29 event_unref(&storage->user->event);
43 struct mail_storage storage;
47 test_begin("mail storage errors");
48 test_init_storage(&storage);
51 mail_storage_set_error(&storage, MAIL_ERROR_PERM, "error1");
52 test_assert(strcmp(mail_storage_get_last_error(&storage, &mail_error), "error1") == 0);
54 test_assert(strcmp(mail_storage_get_last_internal_error(&storage, &mail_error), "error1") == 0);
56 test_assert(!storage.last_error_is_internal);
59 mail_storage_set_error(&storage, MAIL_ERROR_PARAMS,
60 mail_storage_get_last_error(&storage, &mail_error));
61 test_assert(strcmp(mail_storage_get_last_error(&storage, &mail_error), "error1") == 0);
63 test_assert(strcmp(mail_storage_get_last_internal_error(&storage, &mail_error), "error1") == 0);
65 test_assert(!storage.last_error_is_internal);
68 mail_storage_clear_error(&storage);
69 test_assert(strcmp(mail_storage_get_last_error(&storage, &mail_error), "BUG: Unknown internal error") == 0);
71 test_assert(strcmp(mail_storage_get_last_internal_error(&storage, &mail_error), "BUG: Unknown internal error") == 0);
73 test_assert(!storage.last_error_is_internal);
77 mail_storage_set_critical(&storage, "critical0");
79 test_assert(strstr(mail_storage_get_last_error(&storage, &mail_error), MAIL_ERRSTR_CRITICAL_MSG) != NULL);
81 test_assert(strcmp(mail_storage_get_last_internal_error(&storage, &mail_error), "critical0") == 0);
83 test_assert(storage.last_error_is_internal);
87 mail_storage_set_internal_error(&storage);
88 test_assert(strstr(mail_storage_get_last_error(&storage, &mail_error), MAIL_ERRSTR_CRITICAL_MSG) != NULL);
90 test_assert(strstr(mail_storage_get_last_internal_error(&storage, &mail_error), MAIL_ERRSTR_CRITICAL_MSG) != NULL);
92 test_assert(!storage.last_error_is_internal);
96 mail_storage_set_critical(&storage, "critical1");
98 test_assert(strstr(mail_storage_get_last_error(&storage, &mail_error), MAIL_ERRSTR_CRITICAL_MSG) != NULL);
100 test_assert(strcmp(mail_storage_get_last_internal_error(&storage, &mail_error), "critical1") == 0);
102 test_assert(storage.last_error_is_internal);
106 mail_storage_set_critical(&storage, "critical2: %s",
107 mail_storage_get_last_internal_error(&storage, &mail_error));
109 test_assert(strstr(mail_storage_get_last_error(&storage, &mail_error), MAIL_ERRSTR_CRITICAL_MSG) != NULL);
111 test_assert(strcmp(mail_storage_get_last_internal_error(&storage, &mail_error), "critical2: critical1") == 0);
113 test_assert(storage.last_error_is_internal);
117 mail_storage_set_critical(&storage, "critical3: %s",
118 mail_storage_get_last_error(&storage, &mail_error));
120 test_assert(strstr(mail_storage_get_last_error(&storage, &mail_error), MAIL_ERRSTR_CRITICAL_MSG) != NULL);
122 errstr = mail_storage_get_last_internal_error(&storage, &mail_error);
126 test_assert(storage.last_error_is_internal);
129 mail_storage_clear_error(&storage);
130 test_assert(strcmp(mail_storage_get_last_error(&storage, &mail_error), "BUG: Unknown internal error") == 0);
132 test_assert(strcmp(mail_storage_get_last_internal_error(&storage, &mail_error), "BUG: Unknown internal error") == 0);
134 test_assert(!storage.last_error_is_internal);
139 mail_storage_set_critical(&storage, "critical4");
140 mail_storage_set_error(&storage, MAIL_ERROR_PARAMS,
141 mail_storage_get_last_internal_error(&storage, &mail_error));
143 test_assert(strcmp(mail_storage_get_last_error(&storage, &mail_error), "critical4") == 0);
145 test_assert(strcmp(mail_storage_get_last_internal_error(&storage, &mail_error), "critical4") == 0);
147 test_assert(!storage.last_error_is_internal);
149 test_deinit_storage(&storage);
155 struct mail_storage storage;
159 test_init_storage(&storage);
162 mail_storage_set_error(&storage, MAIL_ERROR_PERM, "regular error 1");
163 mail_storage_last_error_push(&storage);
167 mail_storage_set_critical(&storage, "critical error 1");
169 mail_storage_last_error_push(&storage);
172 mail_storage_set_error(&storage, MAIL_ERROR_PARAMS, "regular error 2");
173 mail_storage_last_error_push(&storage);
177 mail_storage_set_critical(&storage, "critical error 2");
179 mail_storage_last_error_push(&storage);
182 mail_storage_clear_error(&storage);
185 mail_storage_last_error_pop(&storage);
186 test_assert(strstr(mail_storage_get_last_error(&storage, &mail_error), MAIL_ERRSTR_CRITICAL_MSG) != NULL);
188 test_assert(strcmp(mail_storage_get_last_internal_error(&storage, &mail_error), "critical error 2") == 0);
190 test_assert(storage.last_error_is_internal);
193 mail_storage_last_error_pop(&storage);
194 test_assert(strcmp(mail_storage_get_last_error(&storage, &mail_error), "regular error 2") == 0);
196 test_assert(strcmp(mail_storage_get_last_internal_error(&storage, &mail_error), "regular error 2") == 0);
198 test_assert(!storage.last_error_is_internal);
201 mail_storage_last_error_pop(&storage);
202 test_assert(strstr(mail_storage_get_last_error(&storage, &mail_error), MAIL_ERRSTR_CRITICAL_MSG) != NULL);
204 test_assert(strcmp(mail_storage_get_last_internal_error(&storage, &mail_error), "critical error 1") == 0);
206 test_assert(storage.last_error_is_internal);
209 mail_storage_last_error_pop(&storage);
210 test_assert(strcmp(mail_storage_get_last_error(&storage, &mail_error), "regular error 1") == 0);
212 test_assert(strcmp(mail_storage_get_last_internal_error(&storage, &mail_error), "regular error 1") == 0);
214 test_assert(!storage.last_error_is_internal);
216 test_deinit_storage(&storage);
673 master_service = master_service_init("test-mail-storage",