Skip to content

Commit

Permalink
feat(tracing): Retroactive unit test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
relaxolotl committed Dec 21, 2021
1 parent 22809b2 commit 2236d71
Showing 1 changed file with 7 additions and 16 deletions.
23 changes: 7 additions & 16 deletions tests/unit/test_tracing.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@ SENTRY_TEST(basic_tracing_context)

sentry_value_t trace_context = sentry__span_get_trace_context(span);
TEST_CHECK(!sentry_value_is_null(trace_context));
TEST_CHECK(!sentry_value_is_null(
sentry_value_get_by_key(trace_context, "trace_id")));
TEST_CHECK(!sentry_value_is_null(
sentry_value_get_by_key(trace_context, "span_id")));
TEST_CHECK(!IS_NULL(trace_context, "trace_id"));
TEST_CHECK(!IS_NULL(trace_context, "span_id"));

const char *span_op
= sentry_value_as_string(sentry_value_get_by_key(trace_context, "op"));
TEST_CHECK_STRING_EQUAL(span_op, "honk.beep");
CHECK_STRING_PROPERTY(trace_context, "op", "honk.beep");

sentry_value_decref(trace_context);
sentry_value_decref(span);
Expand Down Expand Up @@ -129,17 +125,12 @@ send_transaction_envelope_test_basic(sentry_envelope_t *envelope, void *data)

sentry_value_t transaction = sentry_envelope_get_transaction(envelope);
TEST_CHECK(!sentry_value_is_null(transaction));
const char *event_id = sentry_value_as_string(
sentry_value_get_by_key(transaction, "event_id"));
TEST_CHECK_STRING_EQUAL(event_id, "4c035723-8638-4c3a-923f-2ab9d08b4018");
CHECK_STRING_PROPERTY(
transaction, "event_id", "4c035723-8638-4c3a-923f-2ab9d08b4018");

if (*called == 1) {
const char *type = sentry_value_as_string(
sentry_value_get_by_key(transaction, "type"));
TEST_CHECK_STRING_EQUAL(type, "transaction");
const char *name = sentry_value_as_string(
sentry_value_get_by_key(transaction, "transaction"));
TEST_CHECK_STRING_EQUAL(name, "honk");
CHECK_STRING_PROPERTY(transaction, "type", "transaction");
CHECK_STRING_PROPERTY(transaction, "transaction", "honk");
}

sentry_envelope_free(envelope);
Expand Down

0 comments on commit 2236d71

Please sign in to comment.