Skip to content

Commit

Permalink
test: PodIT don't rely on PodResource.file.read to verify the content…
Browse files Browse the repository at this point in the history
…s of the upload test

Signed-off-by: Marc Nuri <marc@marcnuri.com>
  • Loading branch information
manusa committed Jun 15, 2023
1 parent 63bcd03 commit 6899cb4
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions kubernetes-itests/src/test/java/io/fabric8/kubernetes/PodIT.java
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ void uploadBinaryFile() throws IOException {
}

@Test
void uploadDir(@TempDir Path toUpload) throws IOException {
void uploadDir(@TempDir Path toUpload) throws Exception {
// Given
final String[] files = new String[] { "1", "2", "a", "b", "c" };
final Path nestedDir = Files.createDirectory(toUpload.resolve("nested"));
Expand All @@ -430,11 +430,13 @@ void uploadDir(@TempDir Path toUpload) throws IOException {
.map(p -> Paths.get("tmp").resolve("upload-dir").resolve(p))
.collect(Collectors.toList());
for (Path pathToCheck : pathsToCheck) {
try (InputStream checkIs = podResource.file("/" + pathToCheck.toString()).read();
BufferedReader br = new BufferedReader(new InputStreamReader(checkIs, StandardCharsets.UTF_8))) {
String result = br.lines().collect(Collectors.joining(System.lineSeparator()));
assertEquals("I'm uploaded" + System.lineSeparator() + pathToCheck.getFileName(), result);
}
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
podResource.writingOutput(baos)
.exec("sh", "-c", String.format("cat /%s", pathToCheck.toString())).exitCode().get();
assertThat(baos)
.extracting(ByteArrayOutputStream::toString)
.asString()
.startsWith("I'm uploaded" + System.lineSeparator() + pathToCheck.getFileName());
}
}

Expand Down

0 comments on commit 6899cb4

Please sign in to comment.