Last active
May 31, 2022 21:26
-
-
Save eddumelendez/18da7801d2b601ddb5ddf1a47508bade to your computer and use it in GitHub Desktop.
Testcontainers and localstack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
awslocal s3api create-bucket --bucket s3-demo | |
echo "s3 bucket created." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Testcontainers | |
class LocalstackTest { | |
@Container | |
private final LocalStackContainer localstack = | |
new LocalStackContainer(DockerImageName.parse("localstack/localstack").withTag("0.14.2")) | |
.withCopyFileToContainer(MountableFile.forClasspathResource("/localstack"), "/docker-entrypoint-initaws.d") | |
.withServices(Service.S3) | |
.waitingFor(Wait.forLogMessage(".*s3 bucket created\\.\n", 1)); | |
@Test | |
void test() throws IOException, InterruptedException { | |
ExecResult execResult = this.localstack.execInContainer("awslocal", "s3api", "list-buckets"); | |
assertThat(execResult.getStdout()).contains("s3-demo"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment