@testcontainers/mongodb 12.0.4 → 12.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StartedMongoDBContainer = exports.MongoDBContainer = void 0;
|
|
3
|
+
exports.StartedMongoDBContainer = exports.MongoDBContainer = exports.StartedMongoDBAtlasLocalContainer = exports.MongoDBAtlasLocalContainer = void 0;
|
|
4
|
+
var mongodb_atlas_local_container_1 = require("./mongodb-atlas-local-container");
|
|
5
|
+
Object.defineProperty(exports, "MongoDBAtlasLocalContainer", { enumerable: true, get: function () { return mongodb_atlas_local_container_1.MongoDBAtlasLocalContainer; } });
|
|
6
|
+
Object.defineProperty(exports, "StartedMongoDBAtlasLocalContainer", { enumerable: true, get: function () { return mongodb_atlas_local_container_1.StartedMongoDBAtlasLocalContainer; } });
|
|
4
7
|
var mongodb_container_1 = require("./mongodb-container");
|
|
5
8
|
Object.defineProperty(exports, "MongoDBContainer", { enumerable: true, get: function () { return mongodb_container_1.MongoDBContainer; } });
|
|
6
9
|
Object.defineProperty(exports, "StartedMongoDBContainer", { enumerable: true, get: function () { return mongodb_container_1.StartedMongoDBContainer; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { AbstractStartedContainer, GenericContainer, StartedTestContainer } from "testcontainers";
|
|
2
|
+
export declare class MongoDBAtlasLocalContainer extends GenericContainer {
|
|
3
|
+
private username;
|
|
4
|
+
private password;
|
|
5
|
+
constructor(image: string);
|
|
6
|
+
withUsername(username: string): this;
|
|
7
|
+
withPassword(password: string): this;
|
|
8
|
+
start(): Promise<StartedMongoDBAtlasLocalContainer>;
|
|
9
|
+
}
|
|
10
|
+
export declare class StartedMongoDBAtlasLocalContainer extends AbstractStartedContainer {
|
|
11
|
+
private readonly username;
|
|
12
|
+
private readonly password;
|
|
13
|
+
constructor(startedTestContainer: StartedTestContainer, username: string | undefined, password: string | undefined);
|
|
14
|
+
getConnectionString(): string;
|
|
15
|
+
getDatabaseConnectionString(databaseName?: string): string;
|
|
16
|
+
private buildConnectionString;
|
|
17
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StartedMongoDBAtlasLocalContainer = exports.MongoDBAtlasLocalContainer = void 0;
|
|
4
|
+
const testcontainers_1 = require("testcontainers");
|
|
5
|
+
const MONGODB_PORT = 27017;
|
|
6
|
+
const DEFAULT_DATABASE_NAME = "test";
|
|
7
|
+
class MongoDBAtlasLocalContainer extends testcontainers_1.GenericContainer {
|
|
8
|
+
username;
|
|
9
|
+
password;
|
|
10
|
+
constructor(image) {
|
|
11
|
+
super(image);
|
|
12
|
+
this.withExposedPorts(MONGODB_PORT)
|
|
13
|
+
.withWaitStrategy(testcontainers_1.Wait.forSuccessfulCommand("runner healthcheck"))
|
|
14
|
+
.withStartupTimeout(120_000);
|
|
15
|
+
}
|
|
16
|
+
withUsername(username) {
|
|
17
|
+
if (!username)
|
|
18
|
+
throw new Error("Username should not be empty.");
|
|
19
|
+
this.username = username;
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
withPassword(password) {
|
|
23
|
+
if (!password)
|
|
24
|
+
throw new Error("Password should not be empty.");
|
|
25
|
+
this.password = password;
|
|
26
|
+
return this;
|
|
27
|
+
}
|
|
28
|
+
async start() {
|
|
29
|
+
if (this.username && this.password) {
|
|
30
|
+
// Note: the Atlas Local image uses MONGODB_INITDB_* (vs MONGO_INITDB_* in mongodb-container.ts).
|
|
31
|
+
// This difference is intentional — do not "fix" it to match the sibling file.
|
|
32
|
+
this.withEnvironment({
|
|
33
|
+
MONGODB_INITDB_ROOT_USERNAME: this.username,
|
|
34
|
+
MONGODB_INITDB_ROOT_PASSWORD: this.password,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return new StartedMongoDBAtlasLocalContainer(await super.start(), this.username, this.password);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.MongoDBAtlasLocalContainer = MongoDBAtlasLocalContainer;
|
|
41
|
+
class StartedMongoDBAtlasLocalContainer extends testcontainers_1.AbstractStartedContainer {
|
|
42
|
+
username;
|
|
43
|
+
password;
|
|
44
|
+
constructor(startedTestContainer, username, password) {
|
|
45
|
+
super(startedTestContainer);
|
|
46
|
+
this.username = username;
|
|
47
|
+
this.password = password;
|
|
48
|
+
}
|
|
49
|
+
getConnectionString() {
|
|
50
|
+
return this.buildConnectionString();
|
|
51
|
+
}
|
|
52
|
+
getDatabaseConnectionString(databaseName = DEFAULT_DATABASE_NAME) {
|
|
53
|
+
return this.buildConnectionString(databaseName);
|
|
54
|
+
}
|
|
55
|
+
buildConnectionString(databaseName) {
|
|
56
|
+
const url = new URL("mongodb://");
|
|
57
|
+
url.hostname = this.getHost();
|
|
58
|
+
url.port = this.getMappedPort(MONGODB_PORT).toString();
|
|
59
|
+
url.pathname = databaseName ? `/${databaseName}` : "/";
|
|
60
|
+
if (this.username && this.password) {
|
|
61
|
+
url.username = this.username;
|
|
62
|
+
url.password = this.password;
|
|
63
|
+
url.searchParams.set("authSource", "admin");
|
|
64
|
+
}
|
|
65
|
+
return url.toString();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.StartedMongoDBAtlasLocalContainer = StartedMongoDBAtlasLocalContainer;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testcontainers/mongodb",
|
|
3
|
-
"version": "12.0
|
|
3
|
+
"version": "12.2.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"mongodb",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"build": "tsc --project tsconfig.build.json"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"mongoose": "^9.
|
|
32
|
+
"mongoose": "^9.10.1"
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"compare-versions": "^6.1.1",
|
|
36
|
-
"testcontainers": "^12.0
|
|
36
|
+
"testcontainers": "^12.2.0"
|
|
37
37
|
}
|
|
38
38
|
}
|