Skip to content

Commit

Permalink
chore: Test more rounds for unsafeDataVia keeping order.
Browse files Browse the repository at this point in the history
  • Loading branch information
He-Pin committed Jan 5, 2025
1 parent b48cb05 commit e2d2ab9
Showing 1 changed file with 22 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -178,13 +178,15 @@ class FlowWithContextSpec extends StreamSpec {
.map(_._1)
.unsafeDataVia(Flow.fromFunction[String, Int] { _.toInt })

SourceWithContext
.fromTuples(Source(data))
.via(baseFlow)
.runWith(TestSink.probe[(Int, Int)])
.request(4)
.expectNext((1, 1), (2, 2), (3, 3), (4, 4))
.expectComplete()
for (_ <- 0 until 64) {
SourceWithContext
.fromTuples(Source(data))
.via(baseFlow)
.runWith(TestSink.probe[(Int, Int)])
.request(4)
.expectNext((1, 1), (2, 2), (3, 3), (4, 4))
.expectComplete()
}
}

"Apply a viaFlow with optional elements using unsafeOptionalVia" in {
Expand All @@ -194,17 +196,19 @@ class FlowWithContextSpec extends StreamSpec {
.asFlowWithContext[Option[String], Int, Int](collapseContext = Tuple2.apply)(extractContext = _._2)
.map(_._1)

SourceWithContext
.fromTuples(Source(data)).via(
FlowWithContext.unsafeOptionalDataVia(
flow,
Flow.fromFunction { (string: String) => string.toInt }
)(Keep.none)
)
.runWith(TestSink.probe[(Option[Int], Int)])
.request(4)
.expectNext((Some(1), 1), (None, 2), (None, 3), (Some(4), 4))
.expectComplete()
for (_ <- 0 until 64) {
SourceWithContext
.fromTuples(Source(data)).via(
FlowWithContext.unsafeOptionalDataVia(
flow,
Flow.fromFunction { (string: String) => string.toInt }
)(Keep.none)
)
.runWith(TestSink.probe[(Option[Int], Int)])
.request(4)
.expectNext((Some(1), 1), (None, 2), (None, 3), (Some(4), 4))
.expectComplete()
}
}
}
}

0 comments on commit e2d2ab9

Please sign in to comment.