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
15 changes: 15 additions & 0 deletions packages/modules/localstack/src/localstack-container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,19 @@ describe("LocalStackContainer", { timeout: 180_000 }, () => {
expect(exitCode).toBe(0);
expect(output).toContain(`${LABEL_TESTCONTAINERS_SESSION_ID}=${sessionId}`);
});

it("should concatenate sessionId label to LAMBDA_DOCKER_FLAGS", async () => {
const container = await new LocalstackContainer()
.withEnvironment({
LAMBDA_DOCKER_FLAGS: `-l mylabel=myvalue`,
})
.start();
const sessionId = container.getLabels()[LABEL_TESTCONTAINERS_SESSION_ID];

const { output, exitCode } = await container.exec(["printenv", "LAMBDA_DOCKER_FLAGS"]);

expect(exitCode).toBe(0);
expect(output).toContain(`${LABEL_TESTCONTAINERS_SESSION_ID}=${sessionId}`);
expect(output).toContain(`mylabel=myvalue`);
});
});
5 changes: 4 additions & 1 deletion packages/modules/localstack/src/localstack-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ export class LocalstackContainer extends GenericContainer {
private async flagLambdaSessionId(): Promise<void> {
const client = await getContainerRuntimeClient();
const reaper = await getReaper(client);
this.withEnvironment({ LAMBDA_DOCKER_FLAGS: `-l ${LABEL_TESTCONTAINERS_SESSION_ID}=${reaper.sessionId}` });

this.withEnvironment({
LAMBDA_DOCKER_FLAGS: `${this.environment["LAMBDA_DOCKER_FLAGS"] ?? ""} -l ${LABEL_TESTCONTAINERS_SESSION_ID}=${reaper.sessionId}`,
});
}

protected override async beforeContainerCreated(): Promise<void> {
Expand Down