Skip to content

Commit

Permalink
Add Transferable.of(String, int) (#5741)
Browse files Browse the repository at this point in the history
The new method adds similar capability of `Transferable.of(byte[], int)`
but for `String`.
  • Loading branch information
eddumelendez committed Aug 18, 2022
1 parent 9fb5db1 commit 20fdee2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,9 @@ tasks.generatePomFileForMavenJavaPublication.finalizedBy(
]
}
)

tasks.japicmp {
methodExcludes = [
"org.testcontainers.images.builder.Transferable#of(java.lang.String,int)"
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ static Transferable of(String string) {
return of(string.getBytes(StandardCharsets.UTF_8));
}

static Transferable of(String string, int fileMode) {
return of(string.getBytes(StandardCharsets.UTF_8), fileMode);
}

static Transferable of(byte[] bytes) {
return of(bytes, DEFAULT_FILE_MODE);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ public void shouldCopyTransferableAsFile() {
}
}

@Test
public void shouldCopyTransferableAsFileWithFileMode() {
try (
GenericContainer<?> container = new GenericContainer<>(TestImages.TINY_IMAGE)
.withStartupCheckStrategy(new NoopStartupCheckStrategy())
.withCopyToContainer(Transferable.of("test", 0777), "/tmp/test")
.waitingFor(new WaitForExitedState(state -> state.getExitCodeLong() > 0))
.withCommand("sh", "-c", "ls -ll /tmp | grep '\\-rwxrwxrwx\\|test' && exit 100")
) {
assertThatThrownBy(container::start).hasStackTraceContaining("Container exited with code 100");
}
}

@Test
public void shouldCopyTransferableAfterMountableFile() {
try (
Expand Down

0 comments on commit 20fdee2

Please sign in to comment.