Hey, why this test fails? I want to implement a “s...
# coroutines
a
Hey, why this test fails? I want to implement a “single instance job” which means there is should be only one active job with specific name in a scope
Copy code
@Test
    fun test() {
        val job = GlobalScope.launch(CoroutineName("my_name")) {
            delay(1000)
        }

        assertEquals("my_name", job[CoroutineName]?.name)
    }
Figured it out, here is working code
Copy code
assertEquals("my_name", (job as AbstractCoroutine<*>).context[CoroutineName]?.name)
😱 1