-
-
Notifications
You must be signed in to change notification settings - Fork 435
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: SentryTransaction#finish should not clear another transaction fr…
- Loading branch information
1 parent
1e7be93
commit 86e9d16
Showing
3 changed files
with
27 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1028,18 +1028,38 @@ class HubTest { | |
} | ||
|
||
@Test | ||
fun `when captureTransaction, scope transaction is cleared`() { | ||
fun `when transaction is set on scope, captureTransaction clears it from the scope`() { | ||
val options = SentryOptions() | ||
options.cacheDirPath = file.absolutePath | ||
options.dsn = "https://[email protected]/proj" | ||
options.setSerializer(mock()) | ||
val sut = Hub(options) | ||
|
||
sut.captureTransaction(SentryTransaction("name", "op"), null) | ||
val transaction = SentryTransaction(TransactionContext("name", "op", true), sut) | ||
sut.configureScope { it.setTransaction(transaction) } | ||
sut.captureTransaction(transaction, null) | ||
sut.configureScope { | ||
assertNull(it.transaction) | ||
} | ||
} | ||
|
||
@Test | ||
fun `when different transaction is set on scope, captureTransaction does not clear it from the scope`() { | ||
val options = SentryOptions() | ||
options.cacheDirPath = file.absolutePath | ||
options.dsn = "https://[email protected]/proj" | ||
options.setSerializer(mock()) | ||
val sut = Hub(options) | ||
|
||
val transaction = SentryTransaction(TransactionContext("name", "op", true), sut) | ||
val anotherTransaction = SentryTransaction(TransactionContext("name", "op", true), sut) | ||
sut.configureScope { it.setTransaction(anotherTransaction) } | ||
sut.captureTransaction(transaction, null) | ||
sut.configureScope { | ||
assertNotNull(it.transaction) | ||
assertEquals(anotherTransaction, it.transaction) | ||
} | ||
} | ||
//endregion | ||
|
||
//region startTransaction tests | ||
|