-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Legger til mock av UnleashService på samme måte som for FeatureToggle…
…Service (#3985) ### 💰 Hva skal gjøres, og hvorfor? I alle tester vil nå `unleashService.isEnabled()` gi `false` og vi får ikke testet at koden som ligger bak togglene fungerer som tiltenkt. Med "gammel" Unleash `FeatureToggleService` ble alle toggler skrudd på i alle enhetstester og integrasjonstester også ble alle verdikjedetester kjørt med toggler både på og av. Har her lagt til tilsvarende logikk for toggles i tester for `UnleashService` som for `FeatureToggleService`. > Vil ikke kunne merge denne før eksisterende "UnleashNext"-toggles ikke feiler tester dersom de er skrudd på. ### 💬 Ønsker du en muntlig gjennomgang? - [ ] Ja - [x] Nei --------- Co-authored-by: halvormundal <[email protected]> Co-authored-by: halvorbmundal <[email protected]>
- Loading branch information
1 parent
c4e9cc5
commit 6692c0c
Showing
6 changed files
with
84 additions
and
4 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
30 changes: 30 additions & 0 deletions
30
src/test/integrasjonstester/kotlin/no/nav/familie/ba/sak/config/UnleashServiceMockConfig.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,30 @@ | ||
package no.nav.familie.ba.sak.config | ||
|
||
import io.mockk.mockk | ||
import no.nav.familie.ba.sak.config.featureToggle.miljø.Profil | ||
import no.nav.familie.ba.sak.config.featureToggle.miljø.erAktiv | ||
import no.nav.familie.unleash.UnleashService | ||
import org.springframework.boot.test.context.TestConfiguration | ||
import org.springframework.context.annotation.Bean | ||
import org.springframework.context.annotation.Primary | ||
import org.springframework.core.env.Environment | ||
|
||
@TestConfiguration | ||
class UnleashServiceMockConfig( | ||
private val unleashService: UnleashService, | ||
private val environment: Environment, | ||
) { | ||
|
||
@Bean | ||
@Primary | ||
fun mockUnleashService(): UnleashService { | ||
if (environment.erAktiv(Profil.Integrasjonstest)) { | ||
val mockUnleashService = mockk<UnleashService>(relaxed = true) | ||
|
||
ClientMocks.clearUnleashServiceMocks(mockUnleashService) | ||
|
||
return mockUnleashService | ||
} | ||
return unleashService | ||
} | ||
} |
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