-
Notifications
You must be signed in to change notification settings - Fork 157
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #671 from KasperskyLab/ISSUE-648-Dont-restore-inte…
…rceptors-in-nested-flaky-safety ISSUE-648: Don't restore flaky safety interceptors in the nested flak…
- Loading branch information
Showing
4 changed files
with
71 additions
and
27 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,5 @@ dependencies { | |
|
||
testImplementation(libs.junit) | ||
testImplementation(libs.truth) | ||
testImplementation(libs.mockk) | ||
} |
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
36 changes: 36 additions & 0 deletions
36
.../test/java/com/kaspersky/kaspresso/flakysafety/scalpel/FlakySafeInterceptorScalpelTest.kt
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.kaspersky.kaspresso.flakysafety.scalpel | ||
|
||
import com.kaspersky.kaspresso.kaspresso.Kaspresso | ||
import io.mockk.mockk | ||
import io.mockk.verify | ||
import org.junit.Test | ||
|
||
class FlakySafeInterceptorScalpelTest { | ||
|
||
private val kaspresso = mockk<Kaspresso>(relaxed = true) | ||
private val scalpelSwitcher = mockk<ScalpelSwitcher>(relaxed = true) | ||
private val scalpel = FlakySafeInterceptorScalpel(kaspresso, scalpelSwitcher) | ||
@Test | ||
fun `GIVEN nested flaky safety WHEN trying to scalp flaky safety interceptors THEN should not scalp interceptors`() { | ||
scalpel.scalpFromLibs() | ||
scalpel.scalpFromLibs() | ||
scalpel.scalpFromLibs() | ||
|
||
verify(exactly = 1) { scalpelSwitcher.attemptTakeScalp(any(), any()) } | ||
} | ||
|
||
@Test | ||
fun `GIVEN nested flaky safety WHEN trying to restore flaky safety interceptors THEN should not restore interceptors`() { | ||
scalpel.scalpFromLibs() | ||
scalpel.scalpFromLibs() | ||
scalpel.scalpFromLibs() | ||
|
||
scalpel.restoreScalpToLibs() | ||
scalpel.restoreScalpToLibs() | ||
|
||
verify(exactly = 0) { scalpelSwitcher.attemptRestoreScalp(any()) } | ||
|
||
scalpel.restoreScalpToLibs() | ||
verify { scalpelSwitcher.attemptRestoreScalp(any()) } | ||
} | ||
} |