Skip to content

Commit 924b1d0

Browse files
jpnurmiclaude
andcommitted
fix(test): use platform-specific path separators in attachment_ref tests
On Windows, paths serialized in attachment-ref JSON payloads contain backslashes. The strstr assertions were hardcoded with forward slashes, causing attachment_ref_copy, attachment_ref_move, and attachment_ref_restore to fail on Windows. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4f9b25c commit 924b1d0

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

tests/unit/test_envelopes.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,8 +1002,13 @@ SENTRY_TEST(attachment_ref_copy)
10021002
payload_json = sentry__value_from_json(payload, payload_len);
10031003
ref_path
10041004
= sentry_value_as_string(sentry_value_get_by_key(payload_json, "path"));
1005+
#ifdef SENTRY_PLATFORM_WINDOWS
1006+
TEST_CHECK(!!strstr(
1007+
ref_path, "\\attachments\\c993afb6-b4ac-48a6-b61b-2558e601d65d\\"));
1008+
#else
10051009
TEST_CHECK(!!strstr(
10061010
ref_path, "/attachments/c993afb6-b4ac-48a6-b61b-2558e601d65d/"));
1011+
#endif
10071012
TEST_CHECK_STRING_EQUAL(sentry_value_as_string(sentry_value_get_by_key(
10081013
payload_json, "content_type")),
10091014
"application/x-dmp");
@@ -1081,9 +1086,15 @@ SENTRY_TEST(attachment_ref_move)
10811086
payload_json = sentry__value_from_json(payload, payload_len);
10821087
ref_path
10831088
= sentry_value_as_string(sentry_value_get_by_key(payload_json, "path"));
1089+
#ifdef SENTRY_PLATFORM_WINDOWS
1090+
TEST_CHECK(!!strstr(ref_path,
1091+
"\\attachments\\c993afb6-b4ac-48a6-b61b-2558e601d65d\\"
1092+
"test_minidump.dmp"));
1093+
#else
10841094
TEST_CHECK(!!strstr(ref_path,
10851095
"/attachments/c993afb6-b4ac-48a6-b61b-2558e601d65d/"
10861096
"test_minidump.dmp"));
1097+
#endif
10871098

10881099
sentry_path_t *dest_path = sentry__path_from_str(ref_path);
10891100
TEST_CHECK(sentry__path_is_file(dest_path));
@@ -1119,9 +1130,15 @@ send_restore_envelope(sentry_envelope_t *envelope, void *data)
11191130
sentry_value_t pj = sentry__value_from_json(payload, payload_len);
11201131
const char *ref_path
11211132
= sentry_value_as_string(sentry_value_get_by_key(pj, "path"));
1133+
#ifdef SENTRY_PLATFORM_WINDOWS
1134+
TEST_CHECK(!!strstr(ref_path,
1135+
"\\attachments\\c993afb6-b4ac-48a6-b61b-2558e601d65d\\"
1136+
"test_minidump.dmp"));
1137+
#else
11221138
TEST_CHECK(!!strstr(ref_path,
11231139
"/attachments/c993afb6-b4ac-48a6-b61b-2558e601d65d/"
11241140
"test_minidump.dmp"));
1141+
#endif
11251142
sentry_value_decref(pj);
11261143
}
11271144

0 commit comments

Comments
 (0)