forked from typeorm/typeorm
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly parse connection URI with query params (typeorm#6390)
ref typeorm#6389 Co-authored-by: Coroliov Oleg <coroliov.o@goparrot.ai>
- Loading branch information
1 parent
7ed4adb
commit b1d6efa
Showing
2 changed files
with
32 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { DriverUtils } from "../../../src/driver/DriverUtils"; | ||
import { expect } from "chai"; | ||
|
||
describe("github issues > #6389 MongoDB URI Connection string with query params", () => { | ||
it("should parse correctly mongodb URI", () => { | ||
const obj: any = { | ||
type: "mongodb", | ||
username: "user", | ||
password: "password", | ||
host: "host", | ||
database: "database", | ||
port: 27017, | ||
}; | ||
|
||
const url = `${obj.type}://${obj.username}:${obj.password}@${obj.host}:${obj.port}/${obj.database}?readPreference=primary`; | ||
const options = DriverUtils.buildDriverOptions({url}); | ||
|
||
expect(options.type).to.eql(obj.type); | ||
expect(options.username).to.eql(obj.username); | ||
expect(options.username).to.eql(obj.username); | ||
expect(options.password).to.eql(obj.password); | ||
expect(options.host).to.eql(obj.host); | ||
expect(options.port).to.eql(obj.port); | ||
expect(options.database).to.eql(obj.database); | ||
}); | ||
}); |