Skip to content

Commit 77c9d21

Browse files
Merge pull request #80 from square/zachklipp/fix-main
Revert unintentional rename of Worker.test method.
2 parents 8a9703f + 9045f96 commit 77c9d21

File tree

6 files changed

+51
-51
lines changed

6 files changed

+51
-51
lines changed

workflow-rx2/src/test/java/com/squareup/workflow/rx2/RxWorkersTest.kt

+26-26
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
*/
1616
package com.squareup.workflow.rx2
1717

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

43-
worker.launchForTestingWith {
43+
worker.test {
4444
subject.onNext("foo")
4545
assertEquals("foo", nextOutput())
4646

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

56-
worker.launchForTestingWith {
56+
worker.test {
5757
subject.onComplete()
5858
assertFinished()
5959
}
@@ -63,7 +63,7 @@ class RxWorkersTest {
6363
val subject = PublishSubject.create<String>()
6464
val worker = subject.asWorker()
6565

66-
worker.launchForTestingWith {
66+
worker.test {
6767
subject.onNext("foo")
6868
assertEquals("foo", nextOutput())
6969

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

79-
worker.launchForTestingWith {
79+
worker.test {
8080
subject.onError(ExpectedException())
8181
assertTrue(getException() is ExpectedException)
8282
}
@@ -90,7 +90,7 @@ class RxWorkersTest {
9090

9191
assertEquals(0, subscriptions)
9292

93-
worker.launchForTestingWith {
93+
worker.test {
9494
assertEquals(1, subscriptions)
9595
}
9696
}
@@ -103,7 +103,7 @@ class RxWorkersTest {
103103

104104
assertEquals(0, disposals)
105105

106-
worker.launchForTestingWith {
106+
worker.test {
107107
assertEquals(0, disposals)
108108
cancelWorker()
109109
assertEquals(1, disposals)
@@ -119,7 +119,7 @@ class RxWorkersTest {
119119
val worker = (subject.toFlowable(MISSING) as Flowable<out String?>)
120120
.asWorker()
121121

122-
worker.launchForTestingWith {
122+
worker.test {
123123
subject.onNext("foo")
124124
assertEquals("foo", nextOutput())
125125

@@ -133,7 +133,7 @@ class RxWorkersTest {
133133
val worker = subject.toFlowable(MISSING)
134134
.asWorker()
135135

136-
worker.launchForTestingWith {
136+
worker.test {
137137
subject.onComplete()
138138
assertFinished()
139139
}
@@ -144,7 +144,7 @@ class RxWorkersTest {
144144
val worker = subject.toFlowable(MISSING)
145145
.asWorker()
146146

147-
worker.launchForTestingWith {
147+
worker.test {
148148
subject.onNext("foo")
149149
assertEquals("foo", nextOutput())
150150

@@ -158,7 +158,7 @@ class RxWorkersTest {
158158
val worker = subject.toFlowable(MISSING)
159159
.asWorker()
160160

161-
worker.launchForTestingWith {
161+
worker.test {
162162
subject.onError(ExpectedException())
163163
assertTrue(getException() is ExpectedException)
164164
}
@@ -173,7 +173,7 @@ class RxWorkersTest {
173173

174174
assertEquals(0, subscriptions)
175175

176-
worker.launchForTestingWith {
176+
worker.test {
177177
assertEquals(1, subscriptions)
178178
}
179179
}
@@ -187,7 +187,7 @@ class RxWorkersTest {
187187

188188
assertEquals(0, cancels)
189189

190-
worker.launchForTestingWith {
190+
worker.test {
191191
assertEquals(0, cancels)
192192
cancelWorker()
193193
assertEquals(1, cancels)
@@ -202,7 +202,7 @@ class RxWorkersTest {
202202
val subject = MaybeSubject.create<String>()
203203
val worker = (subject as Maybe<out String?>).asWorker()
204204

205-
worker.launchForTestingWith {
205+
worker.test {
206206
subject.onSuccess("foo")
207207
assertEquals("foo", nextOutput())
208208
assertFinished()
@@ -213,7 +213,7 @@ class RxWorkersTest {
213213
val subject = MaybeSubject.create<String>()
214214
val worker = subject.asWorker()
215215

216-
worker.launchForTestingWith {
216+
worker.test {
217217
subject.onComplete()
218218
assertFinished()
219219
}
@@ -223,7 +223,7 @@ class RxWorkersTest {
223223
val subject = MaybeSubject.create<String>()
224224
val worker = subject.asWorker()
225225

226-
worker.launchForTestingWith {
226+
worker.test {
227227
subject.onError(ExpectedException())
228228
assertTrue(getException() is ExpectedException)
229229
}
@@ -237,7 +237,7 @@ class RxWorkersTest {
237237

238238
assertEquals(0, subscriptions)
239239

240-
worker.launchForTestingWith {
240+
worker.test {
241241
assertEquals(1, subscriptions)
242242
}
243243
}
@@ -250,7 +250,7 @@ class RxWorkersTest {
250250

251251
assertEquals(0, cancels)
252252

253-
worker.launchForTestingWith {
253+
worker.test {
254254
assertEquals(0, cancels)
255255
cancelWorker()
256256
assertEquals(1, cancels)
@@ -265,7 +265,7 @@ class RxWorkersTest {
265265
val subject = SingleSubject.create<String>()
266266
val worker = (subject as Single<out String?>).asWorker()
267267

268-
worker.launchForTestingWith {
268+
worker.test {
269269
subject.onSuccess("foo")
270270
assertEquals("foo", nextOutput())
271271
assertFinished()
@@ -276,7 +276,7 @@ class RxWorkersTest {
276276
val subject = SingleSubject.create<String>()
277277
val worker = subject.asWorker()
278278

279-
worker.launchForTestingWith {
279+
worker.test {
280280
subject.onError(ExpectedException())
281281
assertTrue(getException() is ExpectedException)
282282
}
@@ -290,7 +290,7 @@ class RxWorkersTest {
290290

291291
assertEquals(0, subscriptions)
292292

293-
worker.launchForTestingWith {
293+
worker.test {
294294
assertEquals(1, subscriptions)
295295
}
296296
}
@@ -303,7 +303,7 @@ class RxWorkersTest {
303303

304304
assertEquals(0, cancels)
305305

306-
worker.launchForTestingWith {
306+
worker.test {
307307
assertEquals(0, cancels)
308308
cancelWorker()
309309
assertEquals(1, cancels)
@@ -318,7 +318,7 @@ class RxWorkersTest {
318318
val subject = CompletableSubject.create()
319319
val worker = subject.asWorker()
320320

321-
worker.launchForTestingWith {
321+
worker.test {
322322
subject.onComplete()
323323
assertFinished()
324324
}
@@ -328,7 +328,7 @@ class RxWorkersTest {
328328
val subject = CompletableSubject.create()
329329
val worker = subject.asWorker()
330330

331-
worker.launchForTestingWith {
331+
worker.test {
332332
subject.onError(ExpectedException())
333333
assertTrue(getException() is ExpectedException)
334334
}
@@ -342,7 +342,7 @@ class RxWorkersTest {
342342

343343
assertEquals(0, subscriptions)
344344

345-
worker.launchForTestingWith {
345+
worker.test {
346346
assertEquals(1, subscriptions)
347347
}
348348
}
@@ -355,7 +355,7 @@ class RxWorkersTest {
355355

356356
assertEquals(0, cancels)
357357

358-
worker.launchForTestingWith {
358+
worker.test {
359359
assertEquals(0, cancels)
360360
cancelWorker()
361361
assertEquals(1, cancels)

workflow-testing/api/workflow-testing.api

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,8 @@ public abstract interface class com/squareup/workflow/testing/WorkerTester {
5252
}
5353

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

5959
public final class com/squareup/workflow/testing/WorkflowTestParams {

workflow-testing/src/main/java/com/squareup/workflow/testing/WorkerTester.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ interface WorkerTester<T> {
6767
/**
6868
* Test a [Worker] by defining assertions on its output within [block].
6969
*/
70-
fun <T> Worker<T>.launchForTestingWith(
70+
fun <T> Worker<T>.test(
7171
timeoutMs: Long = DEFAULT_TIMEOUT_MS,
7272
block: suspend WorkerTester<T>.() -> Unit
7373
) {

workflow-testing/src/test/java/com/squareup/workflow/FlowWorkersTest.kt

+8-8
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.squareup.workflow
1919

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

4040
@Test fun `flow emits`() {
41-
worker.launchForTestingWith {
41+
worker.test {
4242
subject.send("foo")
4343
assertEquals("foo", nextOutput())
4444

@@ -48,14 +48,14 @@ class FlowWorkersTest {
4848
}
4949

5050
@Test fun `flow finishes`() {
51-
worker.launchForTestingWith {
51+
worker.test {
5252
subject.close()
5353
assertFinished()
5454
}
5555
}
5656

5757
@Test fun `flow finishes after emitting interleaved`() {
58-
worker.launchForTestingWith {
58+
worker.test {
5959
subject.send("foo")
6060
assertEquals("foo", nextOutput())
6161

@@ -65,7 +65,7 @@ class FlowWorkersTest {
6565
}
6666

6767
@Test fun `flow finishes after emitting grouped`() {
68-
worker.launchForTestingWith {
68+
worker.test {
6969
subject.send("foo")
7070
subject.close()
7171

@@ -75,7 +75,7 @@ class FlowWorkersTest {
7575
}
7676

7777
@Test fun `flow throws`() {
78-
worker.launchForTestingWith {
78+
worker.test {
7979
subject.close(ExpectedException())
8080
assertTrue(getException() is ExpectedException)
8181
}
@@ -87,7 +87,7 @@ class FlowWorkersTest {
8787

8888
assertEquals(0, collections)
8989

90-
worker.launchForTestingWith {
90+
worker.test {
9191
assertEquals(1, collections)
9292
}
9393
}
@@ -98,7 +98,7 @@ class FlowWorkersTest {
9898

9999
assertEquals(0, cancellations)
100100

101-
worker.launchForTestingWith {
101+
worker.test {
102102
assertEquals(0, cancellations)
103103
cancelWorker()
104104
assertEquals(1, cancellations)

workflow-testing/src/test/java/com/squareup/workflow/LifecycleWorkerTest.kt

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
package com.squareup.workflow
1919

20-
import com.squareup.workflow.testing.launchForTestingWith
20+
import com.squareup.workflow.testing.test
2121
import kotlinx.coroutines.CoroutineScope
2222
import kotlinx.coroutines.Dispatchers.Unconfined
2323
import kotlinx.coroutines.flow.launchIn
@@ -55,7 +55,7 @@ class LifecycleWorkerTest {
5555
}
5656
}
5757

58-
worker.launchForTestingWith {
58+
worker.test {
5959
assertFalse(onCancelledCalled)
6060
cancelWorker()
6161

0 commit comments

Comments
 (0)