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
3 changes: 3 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ It captures practical rules that prevent avoidable CI and PR churn.
- If new learnings or misunderstandings are discovered, propose an `AGENTS.md` update in the same PR.
- In docs Markdown, keep `<!--codeinclude-->` blocks tight with no blank lines between the markers and the include line, or the rendered snippet will contain blank lines between code lines.
- Codeinclude `inside_block:<name>` selects the block after the first line that contains `<name>` anywhere, so a marker whose name also appears earlier in the file (for example inside another marker's name) silently includes the wrong block. The `Docs` workflow runs `mkdocs build --strict`, which fails when a marker or included file is missing but cannot catch this.
- Fix the root cause. A change that only makes a failure less likely is not a fix.
- Arbitrary delays (`sleep`), repeating a check, or adding retries do not remove a race; they hide it.
- For readiness problems, wait on a deterministic signal of the state you need. If no such signal exists, say so rather than shipping a mitigation as a fix.
- Tests should verify observable behavior changes, not only internal/config state.
- Example: for a security option, assert a real secure/insecure behavior difference.
- Tests should not pull container images that the test suite does not already pull.
Expand Down
16 changes: 10 additions & 6 deletions packages/modules/mongodb/src/mongodb-atlas-local-container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe("MongoDBAtlasLocalContainer", { timeout: 240_000 }, () => {
it("should connect to mongodb atlas local", async () => {
await using container = await new MongoDBAtlasLocalContainer(IMAGE).start();

const db = mongoose.createConnection(container.getConnectionString(), { directConnection: true });
const db = await mongoose.createConnection(container.getConnectionString(), { directConnection: true }).asPromise();

const obj = { value: 1 };
const collection = db.collection("test");
Expand All @@ -79,7 +79,9 @@ describe("MongoDBAtlasLocalContainer", { timeout: 240_000 }, () => {
.withPassword("customPassword")
.start();

const db = mongoose.createConnection(container.getDatabaseConnectionString(), { directConnection: true });
const db = await mongoose
.createConnection(container.getDatabaseConnectionString(), { directConnection: true })
.asPromise();

const obj = { value: 1 };
const collection = db.collection("test");
Expand All @@ -95,10 +97,12 @@ describe("MongoDBAtlasLocalContainer", { timeout: 240_000 }, () => {
// createAtlasIndexAndSearchIt {
await using atlasLocalContainer = await new MongoDBAtlasLocalContainer(IMAGE).start();

const db = mongoose.createConnection(atlasLocalContainer.getConnectionString(), {
dbName: "test",
directConnection: true,
});
const db = await mongoose
.createConnection(atlasLocalContainer.getConnectionString(), {
dbName: "test",
directConnection: true,
})
.asPromise();

try {
const collection = db.collection("test");
Expand Down
4 changes: 2 additions & 2 deletions packages/modules/mongodb/src/mongodb-container.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ describe("MongoDBContainer", { timeout: 240_000 }, () => {
// connectMongo {
await using container = await new MongoDBContainer(image).start();

const db = mongoose.createConnection(container.getConnectionString(), { directConnection: true });
const db = await mongoose.createConnection(container.getConnectionString(), { directConnection: true }).asPromise();

const obj = { value: 1 };
const collection = db.collection("test");
Expand All @@ -30,7 +30,7 @@ describe("MongoDBContainer", { timeout: 240_000 }, () => {
.start();
// }

const db = mongoose.createConnection(container.getConnectionString(), { directConnection: true });
const db = await mongoose.createConnection(container.getConnectionString(), { directConnection: true }).asPromise();

const result = await db.collection("test").insertOne({ title: "test" });
const resultId = result.insertedId.toString();
Expand Down
Loading