Skip to content

Instantly share code, notes, and snippets.

@KwabenBerko
Created July 4, 2023 09:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KwabenBerko/f5f46cece20cd9cec2bf2b5e65616aa0 to your computer and use it in GitHub Desktop.
Save KwabenBerko/f5f46cece20cd9cec2bf2b5e65616aa0 to your computer and use it in GitHub Desktop.
Mutex Enabled Component Test
@OptIn(ExperimentalCoroutinesApi::class)
class MutexEnabledComponentTest {
@Test
fun `should call refresh function only once`() = runTest {
val jobs = mutableListOf<Job>()
val component = MutexEnabledComponent()
repeat(10){
jobs += launch { component.refresh() }
}
jobs.joinAll()
assertEquals(1, component.refreshesCount)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment