|
3 | 3 | #include "sentry_envelope.h" |
4 | 4 | #include "sentry_options.h" |
5 | 5 | #include "sentry_path.h" |
| 6 | +#include "sentry_retry.h" |
6 | 7 | #include "sentry_testsupport.h" |
7 | 8 | #include "sentry_uuid.h" |
8 | 9 | #include "sentry_value.h" |
@@ -73,20 +74,24 @@ SENTRY_TEST(cache_keep) |
73 | 74 | sentry_envelope_write_to_path(envelope, old_envelope_path) == 0); |
74 | 75 | sentry_envelope_free(envelope); |
75 | 76 |
|
76 | | - sentry_path_t *cached_envelope_path |
77 | | - = sentry__path_join_str(cache_path, envelope_filename); |
78 | | - TEST_ASSERT(!!cached_envelope_path); |
79 | | - |
80 | 77 | TEST_ASSERT(sentry__path_is_file(old_envelope_path)); |
81 | | - TEST_ASSERT(!sentry__path_is_file(cached_envelope_path)); |
82 | 78 |
|
83 | 79 | sentry__process_old_runs(options, 0); |
84 | 80 |
|
85 | 81 | TEST_ASSERT(!sentry__path_is_file(old_envelope_path)); |
86 | | - TEST_ASSERT(sentry__path_is_file(cached_envelope_path)); |
| 82 | + |
| 83 | + int count = 0; |
| 84 | + sentry_pathiter_t *iter = sentry__path_iter_directory(cache_path); |
| 85 | + const sentry_path_t *entry; |
| 86 | + while (iter && (entry = sentry__pathiter_next(iter)) != NULL) { |
| 87 | + if (sentry__path_ends_with(entry, ".envelope")) { |
| 88 | + count++; |
| 89 | + } |
| 90 | + } |
| 91 | + sentry__pathiter_free(iter); |
| 92 | + TEST_CHECK_INT_EQUAL(count, 1); |
87 | 93 |
|
88 | 94 | sentry__path_free(old_envelope_path); |
89 | | - sentry__path_free(cached_envelope_path); |
90 | 95 | sentry__path_free(old_run_path); |
91 | 96 | sentry__path_free(cache_path); |
92 | 97 | sentry_free(envelope_filename); |
@@ -328,15 +333,22 @@ SENTRY_TEST(cache_consent_revoked) |
328 | 333 | sentry_value_new_message_event(SENTRY_LEVEL_INFO, "test", "revoked")); |
329 | 334 |
|
330 | 335 | int count = 0; |
| 336 | + bool is_retry_format = false; |
331 | 337 | sentry_pathiter_t *iter = sentry__path_iter_directory(cache_path); |
332 | 338 | const sentry_path_t *entry; |
333 | 339 | while (iter && (entry = sentry__pathiter_next(iter)) != NULL) { |
334 | 340 | if (sentry__path_ends_with(entry, ".envelope")) { |
335 | 341 | count++; |
| 342 | + uint64_t ts; |
| 343 | + int attempt; |
| 344 | + const char *uuid; |
| 345 | + is_retry_format = sentry__parse_cache_filename( |
| 346 | + sentry__path_filename(entry), &ts, &attempt, &uuid); |
336 | 347 | } |
337 | 348 | } |
338 | 349 | sentry__pathiter_free(iter); |
339 | 350 | TEST_CHECK_INT_EQUAL(count, 1); |
| 351 | + TEST_CHECK(is_retry_format); |
340 | 352 |
|
341 | 353 | sentry__path_free(cache_path); |
342 | 354 | sentry_close(); |
@@ -413,21 +425,32 @@ SENTRY_TEST(cache_consent_revoked_old_run) |
413 | 425 | sentry_envelope_write_to_path(envelope, old_envelope_path) == 0); |
414 | 426 | sentry_envelope_free(envelope); |
415 | 427 |
|
416 | | - sentry_path_t *cached_envelope_path |
417 | | - = sentry__path_join_str(cache_path, envelope_filename); |
418 | | - TEST_ASSERT(!!cached_envelope_path); |
419 | | - |
420 | 428 | TEST_ASSERT(sentry__path_is_file(old_envelope_path)); |
421 | | - TEST_ASSERT(!sentry__path_is_file(cached_envelope_path)); |
422 | 429 |
|
423 | 430 | sentry__process_old_runs(options, 0); |
424 | 431 |
|
425 | 432 | TEST_ASSERT(!sentry__path_is_file(old_envelope_path)); |
426 | | - TEST_ASSERT(sentry__path_is_file(cached_envelope_path)); |
427 | 433 | TEST_ASSERT(!sentry__path_is_dir(old_run_path)); |
428 | 434 |
|
| 435 | + int count = 0; |
| 436 | + bool is_retry_format = false; |
| 437 | + sentry_pathiter_t *iter = sentry__path_iter_directory(cache_path); |
| 438 | + const sentry_path_t *entry; |
| 439 | + while (iter && (entry = sentry__pathiter_next(iter)) != NULL) { |
| 440 | + if (sentry__path_ends_with(entry, ".envelope")) { |
| 441 | + count++; |
| 442 | + uint64_t ts; |
| 443 | + int attempt; |
| 444 | + const char *uuid; |
| 445 | + is_retry_format = sentry__parse_cache_filename( |
| 446 | + sentry__path_filename(entry), &ts, &attempt, &uuid); |
| 447 | + } |
| 448 | + } |
| 449 | + sentry__pathiter_free(iter); |
| 450 | + TEST_CHECK_INT_EQUAL(count, 1); |
| 451 | + TEST_CHECK(is_retry_format); |
| 452 | + |
429 | 453 | sentry__path_free(old_envelope_path); |
430 | | - sentry__path_free(cached_envelope_path); |
431 | 454 | sentry__path_free(old_run_path); |
432 | 455 | sentry__path_free(cache_path); |
433 | 456 | sentry_free(envelope_filename); |
|
0 commit comments