Skip to content

Commit 97d3cce

Browse files
committed
fix: Adding start in privileged mode
1 parent ad5d230 commit 97d3cce

File tree

5 files changed

+11
-7
lines changed

5 files changed

+11
-7
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eresearchqut/jest-testcontainers",
3-
"version": "3.7.0",
3+
"version": "3.7.1",
44
"description": "Jest preset for starting docker containers that stay up while your tests run.",
55
"main": "dist/index",
66
"types": "dist/index",

src/config.spec.ts

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ describe("config", () => {
88
// Arrange
99
const firstContainer: any = {
1010
image: "first",
11+
privileged: true,
1112
wait: {
1213
text: "hello",
1314
type: "text"
@@ -35,6 +36,7 @@ describe("config", () => {
3536
const expectedConfig: JestTestcontainersConfig = {
3637
first: {
3738
image: "first",
39+
privileged: true,
3840
wait: {
3941
text: "hello",
4042
type: "text"

src/config.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export interface SingleContainerConfig {
4343
command?: string[];
4444
entrypoint?: string[];
4545
resourcesQuota?: ResourcesQuotaConfig;
46-
withPrivilegedMode?: boolean;
46+
privileged?: boolean;
4747
}
4848

4949
interface PortsWaitConfig {
@@ -185,6 +185,7 @@ function parseContainerConfig(config: any): JestTestcontainersConfig {
185185
command,
186186
entrypoint,
187187
resourcesQuota,
188+
privileged
188189
} = config;
189190
const parsed = {
190191
image,
@@ -197,6 +198,7 @@ function parseContainerConfig(config: any): JestTestcontainersConfig {
197198
command,
198199
entrypoint,
199200
resourcesQuota,
201+
privileged
200202
};
201203

202204
return Object.keys(parsed).reduce(

src/containers.spec.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ describe("containers", () => {
8383
// Arrange
8484
const config: SingleContainerConfig = {
8585
image: "redis",
86-
withPrivilegedMode: true
86+
privileged: true
8787
};
8888

8989
// Act

src/containers.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,10 @@ const addResourcesQuotaToContainer = (resourcesQuota?: ResourcesQuotaConfig) =>
102102
return container.withResourcesQuota(resourcesQuota);
103103
}
104104

105-
const addWithPrivilegedMode = (withPrivilegedMode?: boolean) => (
105+
const addWithPrivilegedMode = (privileged?: boolean) => (
106106
container: TestContainer
107107
): TestContainer => {
108-
if (!withPrivilegedMode) {
108+
if (privileged === undefined || !privileged) {
109109
return container;
110110
}
111111
return container.withPrivilegedMode();
@@ -125,7 +125,7 @@ export function buildTestcontainer(
125125
command,
126126
entrypoint,
127127
resourcesQuota,
128-
withPrivilegedMode
128+
privileged
129129
} = containerConfig;
130130
const sanitizedTag = tag ?? "latest";
131131
const container = new GenericContainer(`${image}:${sanitizedTag}`);
@@ -137,7 +137,7 @@ export function buildTestcontainer(
137137
addCommandToContainer(command),
138138
addEntrypointToContainer(entrypoint),
139139
addResourcesQuotaToContainer(resourcesQuota),
140-
addWithPrivilegedMode(withPrivilegedMode)
140+
addWithPrivilegedMode(privileged)
141141
].reduce<TestContainer>(
142142
(res, func) => func(res),
143143
addNameToContainer(name)(container)

0 commit comments

Comments
 (0)