Skip to content

Commit

Permalink
Add documentation entry for runWithOverrides
Browse files Browse the repository at this point in the history
  • Loading branch information
RustedBones committed Dec 5, 2023
1 parent 8919966 commit daa9ff7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ class PipelineTestUtilsTest
}

"runWithOverride" should "override named transforms from the pipeline" in {
// #PipelineTestUtilsTest_example_run_with_overrides
runWithOverrides(
TransformOverride.of("multiply", (v: Int) => v * v),
TransformOverride.ofIter("append", (v: Int) => Seq(v + "c", v + "d"))
Expand All @@ -77,6 +78,7 @@ class PipelineTestUtilsTest

result should containInAnyOrder(Seq("1c", "1d", "4c", "4d", "9c", "9d"))
}
// #PipelineTestUtilsTest_example_run_with_overrides
}

it should "override named transforms if type signature are compatible" in {
Expand Down
4 changes: 4 additions & 0 deletions site/src/main/paradox/Scio-Unit-Tests.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,10 @@ Can be overridden with static mock data:

@@snip [JobTestTest.scala](/scio-test/src/test/scala/com/spotify/scio/testing/JobTestTest.scala) { #JobTestTest_example_source_mock }

It is alo possible to override a named `PTransform` during partial pipeline testing with `runWithOverrides`.

@@snip [PipelineTestUtilsTest.scala](/scio-test/src/test/scala/com/spotify/scio/testing/PipelineTestUtilsTest.scala) { #PipelineTestUtilsTest_example_run_with_overrides }

Due to type erasure it is possible to provide the incorrect types for the transform and the error will not be caught until runtime.

If you've specified the incorrect input type, scio will attempt to detect the error and throw an `IllegalArgumentException`,
Expand Down

0 comments on commit daa9ff7

Please sign in to comment.