Sqldelight: Publish FlowAssert as a library?

Created on 18 Jul 2019  Â·  6Comments  Â·  Source: cashapp/sqldelight

I like the FlowAssert test DSL for its resemblance to the RxJava2 test API. Are there plans to publish it as a standalone library / artifact or contribute to kotlinx.coroutines?

publishing

Most helpful comment

I would consider it as a personal project

On Wed, Jul 17, 2019 at 9:51 PM ychescale9 notifications@github.com wrote:

I like the FlowAssert test DSL
https://github.com/square/sqldelight/blob/bd1957e85221a219a2b5cc2666f8bc3bdf674d23/extensions/coroutines-extensions/src/commonTest/kotlin/com/squareup/sqldelight/runtime/coroutines/FlowAssert.kt
for its resemblance to the RxJava2 test API. Are there plans to publish it
as a standalone library / artifact or contribute to kotlinx.coroutines?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/square/sqldelight/issues/1416?email_source=notifications&email_token=AAAQIEITP4GMECUXUAZILULP77ECVA5CNFSM4IEWGCSKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G74P4LQ,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAQIEMQNVVZOE76ORRBWZ3P77ECVANCNFSM4IEWGCSA
.

All 6 comments

I would consider it as a personal project

On Wed, Jul 17, 2019 at 9:51 PM ychescale9 notifications@github.com wrote:

I like the FlowAssert test DSL
https://github.com/square/sqldelight/blob/bd1957e85221a219a2b5cc2666f8bc3bdf674d23/extensions/coroutines-extensions/src/commonTest/kotlin/com/squareup/sqldelight/runtime/coroutines/FlowAssert.kt
for its resemblance to the RxJava2 test API. Are there plans to publish it
as a standalone library / artifact or contribute to kotlinx.coroutines?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/square/sqldelight/issues/1416?email_source=notifications&email_token=AAAQIEITP4GMECUXUAZILULP77ECVA5CNFSM4IEWGCSKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G74P4LQ,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAQIEMQNVVZOE76ORRBWZ3P77ECVANCNFSM4IEWGCSA
.

I found some limitations that I want to address. I'm still going to
filter-branch it out, release an 0.1, and update SQL Delight to use it.
I'll leave this issue open to track that.

On Wed, Jul 17, 2019 at 11:25 PM Jake Wharton jakewharton@gmail.com wrote:

I would consider it as a personal project

On Wed, Jul 17, 2019 at 9:51 PM ychescale9 notifications@github.com
wrote:

I like the FlowAssert test DSL
https://github.com/square/sqldelight/blob/bd1957e85221a219a2b5cc2666f8bc3bdf674d23/extensions/coroutines-extensions/src/commonTest/kotlin/com/squareup/sqldelight/runtime/coroutines/FlowAssert.kt
for its resemblance to the RxJava2 test API. Are there plans to publish it
as a standalone library / artifact or contribute to kotlinx.coroutines?

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
https://github.com/square/sqldelight/issues/1416?email_source=notifications&email_token=AAAQIEITP4GMECUXUAZILULP77ECVA5CNFSM4IEWGCSKYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4G74P4LQ,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAAQIEMQNVVZOE76ORRBWZ3P77ECVANCNFSM4IEWGCSA
.

@JakeWharton when u do dis

yeah let's do this

Not sure what things will be taken into consideration for the published version of FlowAssert, but looking at the current implementation, it is somewhat similar to a collectToList { … } utility I came up with where it's usages would be like so:

@Test
fun test() = runBlockingTest {
    val values = fooFlow.collectToList {
        // perform actions that result in emissions here
    }

    // Assert on the contents of the returned List here
}

The similarity is that it too internally launches a collector Coroutine and uses a Channel to send the values and produce a List of values emitted.

One thing I noticed is that when I used Hot Flows for my mock dependencies, such as Channel.asFlow() or MutableStateFlow, and then performed updates within the collectToList block, many of the values get dropped unless the test explicitly invokes yield() after each update. Based on the discussion in https://github.com/Kotlin/kotlinx.coroutines/issues/2082, it seems this behavior is expected. If for such tests I would want to avoid using yield(), then the inner launched Coroutine that performs the collection would have to be launched using Dispatchers.Unconfined. Just thought I'd share in case it helps. Really looking forward to an official FlowAssert library! 😃

Was this page helpful?
0 / 5 - 0 ratings

Related issues

headsvk picture headsvk  Â·  3Comments

jrodbx picture jrodbx  Â·  4Comments

JiongBull picture JiongBull  Â·  3Comments

rharter picture rharter  Â·  4Comments

KChernenko picture KChernenko  Â·  4Comments