Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions docs/modules/s3mock.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# S3Mock

## Install

```bash
npm install @testcontainers/s3mock --save-dev
```

## Examples

These examples use the following libraries:

- [@aws-sdk/client-s3](https://www.npmjs.com/package/@aws-sdk/client-s3)

npm install @aws-sdk/client-s3

Choose an image from the [container registry](https://hub.docker.com/r/adobe/s3mock) and substitute `IMAGE`.

### Create a S3 bucket

<!--codeinclude-->
[](../../packages/modules/s3mock/src/s3mock-container.test.ts) inside_block:s3mockCreateS3Bucket
<!--/codeinclude-->
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ nav:
- RabbitMQ: modules/rabbitmq.md
- Redis: modules/redis.md
- Redpanda: modules/redpanda.md
- S3Mock: modules/s3mock.md
- ScyllaDB: modules/scylladb.md
- Selenium: modules/selenium.md
- ToxiProxy: modules/toxiproxy.md
Expand Down
47 changes: 37 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions packages/modules/s3mock/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM adobe/s3mock:4.9.1
38 changes: 38 additions & 0 deletions packages/modules/s3mock/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"name": "@testcontainers/s3mock",
"version": "11.7.2",
"license": "MIT",
"keywords": [
"s3mock",
"aws",
"testing",
"docker",
"testcontainers"
],
"description": "S3Mock module for Testcontainers",
"homepage": "https://github.com/testcontainers/testcontainers-node#readme",
"repository": {
"type": "git",
"url": "git+https://github.com/testcontainers/testcontainers-node.git"
},
"bugs": {
"url": "https://github.com/testcontainers/testcontainers-node/issues"
},
"main": "build/index.js",
"files": [
"build"
],
"publishConfig": {
"access": "public"
},
"scripts": {
"prepack": "shx cp ../../../README.md . && shx cp ../../../LICENSE .",
"build": "tsc --project tsconfig.build.json"
},
"dependencies": {
"testcontainers": "^11.7.2"
},
"devDependencies": {
"@aws-sdk/client-s3": "^3.913.0"
}
}
1 change: 1 addition & 0 deletions packages/modules/s3mock/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { S3MockContainer, StartedS3MockContainer } from "./s3mock-container";
29 changes: 29 additions & 0 deletions packages/modules/s3mock/src/s3mock-container.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { CreateBucketCommand, HeadBucketCommand, S3Client } from "@aws-sdk/client-s3";
import { getImage } from "../../../testcontainers/src/utils/test-helper";
import { S3MockContainer } from "./s3mock-container";

const IMAGE = getImage(__dirname);

describe("S3MockContainer", { timeout: 180_000 }, () => {
it("should create a S3 bucket", async () => {
// s3mockCreateS3Bucket {
await using container = await new S3MockContainer(IMAGE).start();

const client = new S3Client({
endpoint: container.getHttpConnectionUrl(),
forcePathStyle: true,
region: "auto",
credentials: {
secretAccessKey: container.getSecretAccessKey(),
accessKeyId: container.getAccessKeyId(),
},
});

const input = { Bucket: "testcontainers" };
const command = new CreateBucketCommand(input);

expect((await client.send(command)).$metadata.httpStatusCode).toEqual(200);
expect((await client.send(new HeadBucketCommand(input))).$metadata.httpStatusCode).toEqual(200);
// }
});
});
Loading
Loading