Skip to content

Commit

Permalink
Add fromParent test
Browse files Browse the repository at this point in the history
  • Loading branch information
pgreze authored Jun 27, 2024
1 parent dc4d950 commit 8faf4a1
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/test/kotlin/com/github/pgreze/process/InputSourceTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,6 @@ class InputSourceTest {
val LINES: List<String> = (0..5).map { "Hello $it" }
}

@Test
fun fromString() = runSuspendTest {
val output = process(
"cat",
stdin = InputSource.fromString(STRING),
stdout = Redirect.CAPTURE
).unwrap()
output shouldBeEqualTo listOf(STRING)
}

@Test
fun fromFile(@TempDir dir: Path) = runSuspendTest {
val input = dir.resolve("input.txt").toFile()
Expand All @@ -47,7 +37,17 @@ class InputSourceTest {
}

@Test
fun fromStream() = runSuspendTest {
fun fromString() = runSuspendTest {
val output = process(
"cat",
stdin = InputSource.fromString(STRING),
stdout = Redirect.CAPTURE
).unwrap()
output shouldBeEqualTo listOf(STRING)
}

@Test
fun fromInputStream() = runSuspendTest {
val inputStream = ByteArrayInputStream(STRING.toByteArray())
val output = process(
"cat",
Expand All @@ -57,6 +57,16 @@ class InputSourceTest {
output shouldBeEqualTo listOf(STRING)
}

@Test
fun fromParent() = runSuspendTest {
val output = process(
"cat",
stdin = InputSource.FromParent,
stdout = Redirect.CAPTURE
).unwrap()
output shouldBeEqualTo listOf("")
}

@Nested
@DisplayName("ensure that input and output are concurrently processed")
inner class AsyncStreams {
Expand Down

0 comments on commit 8faf4a1

Please sign in to comment.