Skip to content

Commit

Permalink
tests: Simplify the guest masquerading
Browse files Browse the repository at this point in the history
  • Loading branch information
CLOVIS-AI committed Jun 17, 2023
1 parent 771f8b7 commit 52e5876
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion test/src/commonMain/kotlin/utils/Masquerade.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@ package opensavvy.formulaide.test.utils
import kotlinx.coroutines.withContext
import opensavvy.backbone.now
import opensavvy.formulaide.core.Auth
import opensavvy.formulaide.core.Guest
import opensavvy.formulaide.core.User
import opensavvy.formulaide.core.User.Role.Companion.role
import opensavvy.formulaide.test.structure.Setup
import opensavvy.formulaide.test.structure.TestScope
import opensavvy.formulaide.test.structure.prepare

suspend fun <T> executeAsGuest(block: suspend () -> T) =
withContext(Auth(User.Role.Guest, null)) { block() }
withContext(Guest) { block() }

suspend fun <T> TestScope.executeAs(employee: User.Ref, block: suspend () -> T) =
withContext(Auth(employee.now().bind().role, employee)) { block() }
Expand Down

0 comments on commit 52e5876

Please sign in to comment.