Skip to content

test: add unit tests for PropagationTargetsUtils#1

Draft
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1774215749-propagation-targets-utils-tests
Draft

test: add unit tests for PropagationTargetsUtils#1
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1774215749-propagation-targets-utils-tests

Conversation

@devin-ai-integration
Copy link
Copy Markdown

📜 Description

Adds a new test file PropagationTargetsUtilsTest.kt with 14 focused unit tests for PropagationTargetsUtils, which previously had zero test coverage.

Tests cover:

  • Empty origins list → returns false
  • Substring matching (origin found within URL)
  • Regex matching (valid regex origin matched against URL)
  • Invalid regex gracefully falling back to substring check
  • Multiple origins (first-match-wins behavior)
  • Exact full-URL match
  • Partial matches (URL prefix, path segment)
  • URI overload delegation to the String-based method
  • Negative cases for each of the above

💡 Motivation and Context

PropagationTargetsUtils controls whether Sentry trace headers are attached to outgoing HTTP requests — a critical piece of distributed tracing. Despite this, the class had no dedicated unit tests. This PR closes that gap with a small, low-risk, test-only change.

💚 How did you test it?

./gradlew :sentry:test --tests "*PropagationTargetsUtilsTest*"
# All 14 tests PASSED

./gradlew :sentry:spotlessApply
# Formatting clean, no changes needed

Reviewer checklist

  • Verify the regex-path tests (lines 28–36) genuinely exercise the url.matches(origin) branch rather than the url.contains(origin) branch (they do — the regex literal is not a substring of the test URL).
  • Confirm no important edge cases are missing (e.g., origins with special characters, very long URLs).

📝 Checklist

  • I added GH Issue ID & Linear ID
  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed.
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

🔮 Next steps

Other sentry/util classes with zero test coverage that could benefit from the same treatment:

  • SampleRateUtils (partially covered), ClassLoaderUtils, ErrorUtils, ScopesUtil, UUIDStringUtils

Link to Devin session: https://app.devin.ai/sessions/23aaff7eb99e45c79503152f36003ab8
Requested by: @aks4396

@devin-ai-integration
Copy link
Copy Markdown
Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant