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
19 changes: 19 additions & 0 deletions packages/modules/redis/src/redis-container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,25 @@ describe.each(IMAGES)("RedisContainer (%s)", { concurrent: false, timeout: 240_0
// }
});

it.concurrent("should load initial data when running as a non-root user", async () => {
await using container = await new RedisContainer(image)
.withUser("redis")
.withInitialData(path.join(__dirname, "initData.redis"))
.start();

const client = createClient({ url: container.getConnectionUrl() });
await client.connect();

const user = {
first_name: "David",
last_name: "Bloom",
dob: "03-MAR-1981",
};
expect(await client.get("user:002")).toBe(JSON.stringify(user));

client.destroy();
});

it.concurrent("should load initial data once", async () => {
await using container = await new RedisContainer(image)
.withInitialData(path.join(__dirname, "initCount.redis"))
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/redis/src/redis-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,12 @@ export class RedisContainer extends GenericContainer {
if (this.initialImportScriptFile) {
this.withCopyFilesToContainer([
{
mode: 666,
mode: 0o644,
source: this.initialImportScriptFile,
target: this.importFilePath,
},
{
mode: 777,
mode: 0o755,
source: path.join(__dirname, "import.sh"),
target: "/tmp/import.sh",
},
Expand Down
19 changes: 19 additions & 0 deletions packages/modules/valkey/src/valkey-container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,25 @@ describe.each(IMAGES)("ValkeyContainer (%s)", { concurrent: false, timeout: 240_
// }
});

it.concurrent("should load initial data when running as a non-root user", async () => {
await using container = await new ValkeyContainer(image)
.withUser("valkey")
.withInitialData(path.join(__dirname, "initData.valkey"))
.start();

const client = createClient({ url: container.getConnectionUrl() });
await client.connect();

const user = {
first_name: "David",
last_name: "Bloom",
dob: "03-MAR-1981",
};
expect(await client.get("user:002")).toBe(JSON.stringify(user));

client.destroy();
});

it.concurrent("should start with username and password", async () => {
// valkeyWithUsernameAndPassword {
const username = "testUser";
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/valkey/src/valkey-container.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,12 @@ export class ValkeyContainer extends GenericContainer {
if (this.initialImportScriptFile) {
this.withCopyFilesToContainer([
{
mode: 666,
mode: 0o644,
source: this.initialImportScriptFile,
target: this.importFilePath,
},
{
mode: 777,
mode: 0o755,
source: path.join(__dirname, "import.sh"),
target: "/tmp/import.sh",
},
Expand Down
2 changes: 2 additions & 0 deletions packages/testcontainers/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export type BindMount = {
export type FileToCopy = {
source: string;
target: string;
/** File permissions as an octal number, for example `0o644`. */
mode?: number;
};

Expand All @@ -35,6 +36,7 @@ export type Content = string | Buffer | Readable;
export type ContentToCopy = {
content: Content;
target: string;
/** File permissions as an octal number, for example `0o644`. */
mode?: number;
};

Expand Down
Loading