From 9d01e38a742d1a7acae3665d1117bde77e59807d Mon Sep 17 00:00:00 2001 From: Claude Date: Fri, 27 Mar 2026 06:08:24 +0000 Subject: [PATCH] =?UTF-8?q?test:=20MongoDB=20normalizeConfig=20aliases=20?= =?UTF-8?q?=E2=80=94=20close=20coverage=20gap=20from=20#482?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The MongoDB driver was added in #482 but driver-normalize.test.ts had zero tests for the MONGODB_ALIASES map. These 8 tests cover all MongoDB-specific alias normalization paths (connectionString, uri, authSource, replicaSet, directConnection, connectTimeoutMS, mongo type alias, and canonical passthrough). Co-Authored-By: Claude Opus 4.6 (1M context) https://claude.ai/code/session_01AhNUh22SS3cRR9GVNiTcit --- .../test/altimate/driver-normalize.test.ts | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/packages/opencode/test/altimate/driver-normalize.test.ts b/packages/opencode/test/altimate/driver-normalize.test.ts index f437e1187c..3311eb47f5 100644 --- a/packages/opencode/test/altimate/driver-normalize.test.ts +++ b/packages/opencode/test/altimate/driver-normalize.test.ts @@ -663,3 +663,85 @@ describe("normalizeConfig — Snowflake private_key edge cases", () => { expect(result.private_key_path).toBeUndefined() }) }) + +// --------------------------------------------------------------------------- +// normalizeConfig — MongoDB aliases +// --------------------------------------------------------------------------- + +describe("normalizeConfig — MongoDB", () => { + test("connectionString → connection_string", () => { + const result = normalizeConfig({ + type: "mongodb", + connectionString: "mongodb://localhost:27017/mydb", + }) + expect(result.connection_string).toBe("mongodb://localhost:27017/mydb") + expect(result.connectionString).toBeUndefined() + }) + + test("uri → connection_string", () => { + const result = normalizeConfig({ + type: "mongodb", + uri: "mongodb://localhost:27017/mydb", + }) + expect(result.connection_string).toBe("mongodb://localhost:27017/mydb") + expect(result.uri).toBeUndefined() + }) + + test("authSource → auth_source", () => { + const result = normalizeConfig({ + type: "mongodb", + authSource: "admin", + }) + expect(result.auth_source).toBe("admin") + expect(result.authSource).toBeUndefined() + }) + + test("replicaSet → replica_set", () => { + const result = normalizeConfig({ + type: "mongodb", + replicaSet: "rs0", + }) + expect(result.replica_set).toBe("rs0") + expect(result.replicaSet).toBeUndefined() + }) + + test("directConnection → direct_connection", () => { + const result = normalizeConfig({ + type: "mongodb", + directConnection: true, + }) + expect(result.direct_connection).toBe(true) + expect(result.directConnection).toBeUndefined() + }) + + test("connectTimeoutMS → connect_timeout", () => { + const result = normalizeConfig({ + type: "mongodb", + connectTimeoutMS: 5000, + }) + expect(result.connect_timeout).toBe(5000) + expect(result.connectTimeoutMS).toBeUndefined() + }) + + test("'mongo' type alias routes to MongoDB aliases", () => { + const result = normalizeConfig({ + type: "mongo", + uri: "mongodb://localhost/test", + }) + expect(result.connection_string).toBe("mongodb://localhost/test") + expect(result.uri).toBeUndefined() + }) + + test("canonical mongodb config passes through unchanged", () => { + const config = { + type: "mongodb", + connection_string: "mongodb://localhost:27017", + user: "admin", + password: "secret", + database: "mydb", + auth_source: "admin", + replica_set: "rs0", + } + expect(normalizeConfig(config)).toEqual(config) + }) +})