Skip to content

Revert unintentional rename of Worker.test method. #80

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 29, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/
package com.squareup.workflow.rx2

import com.squareup.workflow.testing.launchForTestingWith
import com.squareup.workflow.testing.test
import io.reactivex.BackpressureStrategy.MISSING
import io.reactivex.Flowable
import io.reactivex.Maybe
Expand All @@ -40,7 +40,7 @@ class RxWorkersTest {
// Should support out-projected parameters.
val worker = (subject as Observable<out String?>).asWorker()

worker.launchForTestingWith {
worker.test {
subject.onNext("foo")
assertEquals("foo", nextOutput())

Expand All @@ -53,7 +53,7 @@ class RxWorkersTest {
val subject = PublishSubject.create<String>()
val worker = subject.asWorker()

worker.launchForTestingWith {
worker.test {
subject.onComplete()
assertFinished()
}
Expand All @@ -63,7 +63,7 @@ class RxWorkersTest {
val subject = PublishSubject.create<String>()
val worker = subject.asWorker()

worker.launchForTestingWith {
worker.test {
subject.onNext("foo")
assertEquals("foo", nextOutput())

Expand All @@ -76,7 +76,7 @@ class RxWorkersTest {
val subject = PublishSubject.create<String>()
val worker = subject.asWorker()

worker.launchForTestingWith {
worker.test {
subject.onError(ExpectedException())
assertTrue(getException() is ExpectedException)
}
Expand All @@ -90,7 +90,7 @@ class RxWorkersTest {

assertEquals(0, subscriptions)

worker.launchForTestingWith {
worker.test {
assertEquals(1, subscriptions)
}
}
Expand All @@ -103,7 +103,7 @@ class RxWorkersTest {

assertEquals(0, disposals)

worker.launchForTestingWith {
worker.test {
assertEquals(0, disposals)
cancelWorker()
assertEquals(1, disposals)
Expand All @@ -119,7 +119,7 @@ class RxWorkersTest {
val worker = (subject.toFlowable(MISSING) as Flowable<out String?>)
.asWorker()

worker.launchForTestingWith {
worker.test {
subject.onNext("foo")
assertEquals("foo", nextOutput())

Expand All @@ -133,7 +133,7 @@ class RxWorkersTest {
val worker = subject.toFlowable(MISSING)
.asWorker()

worker.launchForTestingWith {
worker.test {
subject.onComplete()
assertFinished()
}
Expand All @@ -144,7 +144,7 @@ class RxWorkersTest {
val worker = subject.toFlowable(MISSING)
.asWorker()

worker.launchForTestingWith {
worker.test {
subject.onNext("foo")
assertEquals("foo", nextOutput())

Expand All @@ -158,7 +158,7 @@ class RxWorkersTest {
val worker = subject.toFlowable(MISSING)
.asWorker()

worker.launchForTestingWith {
worker.test {
subject.onError(ExpectedException())
assertTrue(getException() is ExpectedException)
}
Expand All @@ -173,7 +173,7 @@ class RxWorkersTest {

assertEquals(0, subscriptions)

worker.launchForTestingWith {
worker.test {
assertEquals(1, subscriptions)
}
}
Expand All @@ -187,7 +187,7 @@ class RxWorkersTest {

assertEquals(0, cancels)

worker.launchForTestingWith {
worker.test {
assertEquals(0, cancels)
cancelWorker()
assertEquals(1, cancels)
Expand All @@ -202,7 +202,7 @@ class RxWorkersTest {
val subject = MaybeSubject.create<String>()
val worker = (subject as Maybe<out String?>).asWorker()

worker.launchForTestingWith {
worker.test {
subject.onSuccess("foo")
assertEquals("foo", nextOutput())
assertFinished()
Expand All @@ -213,7 +213,7 @@ class RxWorkersTest {
val subject = MaybeSubject.create<String>()
val worker = subject.asWorker()

worker.launchForTestingWith {
worker.test {
subject.onComplete()
assertFinished()
}
Expand All @@ -223,7 +223,7 @@ class RxWorkersTest {
val subject = MaybeSubject.create<String>()
val worker = subject.asWorker()

worker.launchForTestingWith {
worker.test {
subject.onError(ExpectedException())
assertTrue(getException() is ExpectedException)
}
Expand All @@ -237,7 +237,7 @@ class RxWorkersTest {

assertEquals(0, subscriptions)

worker.launchForTestingWith {
worker.test {
assertEquals(1, subscriptions)
}
}
Expand All @@ -250,7 +250,7 @@ class RxWorkersTest {

assertEquals(0, cancels)

worker.launchForTestingWith {
worker.test {
assertEquals(0, cancels)
cancelWorker()
assertEquals(1, cancels)
Expand All @@ -265,7 +265,7 @@ class RxWorkersTest {
val subject = SingleSubject.create<String>()
val worker = (subject as Single<out String?>).asWorker()

worker.launchForTestingWith {
worker.test {
subject.onSuccess("foo")
assertEquals("foo", nextOutput())
assertFinished()
Expand All @@ -276,7 +276,7 @@ class RxWorkersTest {
val subject = SingleSubject.create<String>()
val worker = subject.asWorker()

worker.launchForTestingWith {
worker.test {
subject.onError(ExpectedException())
assertTrue(getException() is ExpectedException)
}
Expand All @@ -290,7 +290,7 @@ class RxWorkersTest {

assertEquals(0, subscriptions)

worker.launchForTestingWith {
worker.test {
assertEquals(1, subscriptions)
}
}
Expand All @@ -303,7 +303,7 @@ class RxWorkersTest {

assertEquals(0, cancels)

worker.launchForTestingWith {
worker.test {
assertEquals(0, cancels)
cancelWorker()
assertEquals(1, cancels)
Expand All @@ -318,7 +318,7 @@ class RxWorkersTest {
val subject = CompletableSubject.create()
val worker = subject.asWorker()

worker.launchForTestingWith {
worker.test {
subject.onComplete()
assertFinished()
}
Expand All @@ -328,7 +328,7 @@ class RxWorkersTest {
val subject = CompletableSubject.create()
val worker = subject.asWorker()

worker.launchForTestingWith {
worker.test {
subject.onError(ExpectedException())
assertTrue(getException() is ExpectedException)
}
Expand All @@ -342,7 +342,7 @@ class RxWorkersTest {

assertEquals(0, subscriptions)

worker.launchForTestingWith {
worker.test {
assertEquals(1, subscriptions)
}
}
Expand All @@ -355,7 +355,7 @@ class RxWorkersTest {

assertEquals(0, cancels)

worker.launchForTestingWith {
worker.test {
assertEquals(0, cancels)
cancelWorker()
assertEquals(1, cancels)
Expand Down
4 changes: 2 additions & 2 deletions workflow-testing/api/workflow-testing.api
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ public abstract interface class com/squareup/workflow/testing/WorkerTester {
}

public final class com/squareup/workflow/testing/WorkerTesterKt {
public static final fun launchForTestingWith (Lcom/squareup/workflow/Worker;JLkotlin/jvm/functions/Function2;)V
public static synthetic fun launchForTestingWith$default (Lcom/squareup/workflow/Worker;JLkotlin/jvm/functions/Function2;ILjava/lang/Object;)V
public static final fun test (Lcom/squareup/workflow/Worker;JLkotlin/jvm/functions/Function2;)V
public static synthetic fun test$default (Lcom/squareup/workflow/Worker;JLkotlin/jvm/functions/Function2;ILjava/lang/Object;)V
}

public final class com/squareup/workflow/testing/WorkflowTestParams {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ interface WorkerTester<T> {
/**
* Test a [Worker] by defining assertions on its output within [block].
*/
fun <T> Worker<T>.launchForTestingWith(
fun <T> Worker<T>.test(
timeoutMs: Long = DEFAULT_TIMEOUT_MS,
block: suspend WorkerTester<T>.() -> Unit
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package com.squareup.workflow

import com.squareup.workflow.testing.launchForTestingWith
import com.squareup.workflow.testing.test
import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.channels.consumeEach
Expand All @@ -38,7 +38,7 @@ class FlowWorkersTest {
private val worker by lazy { source.asWorker() }

@Test fun `flow emits`() {
worker.launchForTestingWith {
worker.test {
subject.send("foo")
assertEquals("foo", nextOutput())

Expand All @@ -48,14 +48,14 @@ class FlowWorkersTest {
}

@Test fun `flow finishes`() {
worker.launchForTestingWith {
worker.test {
subject.close()
assertFinished()
}
}

@Test fun `flow finishes after emitting interleaved`() {
worker.launchForTestingWith {
worker.test {
subject.send("foo")
assertEquals("foo", nextOutput())

Expand All @@ -65,7 +65,7 @@ class FlowWorkersTest {
}

@Test fun `flow finishes after emitting grouped`() {
worker.launchForTestingWith {
worker.test {
subject.send("foo")
subject.close()

Expand All @@ -75,7 +75,7 @@ class FlowWorkersTest {
}

@Test fun `flow throws`() {
worker.launchForTestingWith {
worker.test {
subject.close(ExpectedException())
assertTrue(getException() is ExpectedException)
}
Expand All @@ -87,7 +87,7 @@ class FlowWorkersTest {

assertEquals(0, collections)

worker.launchForTestingWith {
worker.test {
assertEquals(1, collections)
}
}
Expand All @@ -98,7 +98,7 @@ class FlowWorkersTest {

assertEquals(0, cancellations)

worker.launchForTestingWith {
worker.test {
assertEquals(0, cancellations)
cancelWorker()
assertEquals(1, cancellations)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package com.squareup.workflow

import com.squareup.workflow.testing.launchForTestingWith
import com.squareup.workflow.testing.test
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers.Unconfined
import kotlinx.coroutines.flow.launchIn
Expand Down Expand Up @@ -55,7 +55,7 @@ class LifecycleWorkerTest {
}
}

worker.launchForTestingWith {
worker.test {
assertFalse(onCancelledCalled)
cancelWorker()

Expand Down
Loading