test: remove hardcoded test from github issue tst 2096 (#6463)

the test had assumed the username, password, host, and port of
the mysql server

this update changes that so the test instead uses the config properly
while still checking that the test works as expected
This commit is contained in:
James Ward 2020-08-02 10:36:32 -04:00 committed by GitHub
parent f270c0bbaf
commit 33041ccde5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View File

@ -7,7 +7,7 @@ describe.skip("github issues > #114 Can not be parsed correctly the URL of pg.",
let connection: Connection;
before(() => {
connection = new Connection({
connection = new Connection({ // Dummy Connection, won't be established
type: "postgres",
url: "postgres://test:test@localhost:5432/test",
});

View File

@ -2,6 +2,7 @@ import "reflect-metadata";
import { expect } from "chai";
import { createConnection } from "../../../src";
import { getTypeOrmConfig } from "../../utils/test-utils";
import {MysqlConnectionOptions} from "../../../src/driver/mysql/MysqlConnectionOptions";
describe("github issues > #2096 [mysql] Database name isn't read from url", () => {
it("should be possible to define a database by connection url for mysql", async () => {
@ -9,10 +10,22 @@ describe("github issues > #2096 [mysql] Database name isn't read from url", () =
// it is important to synchronize here, to trigger EntityMetadataValidator.validate
// that previously threw the error where the database on the driver object was undefined
if (config.find(c => c.name === "mysql" && !c.skip)) {
const mysqlConfig: MysqlConnectionOptions = config.find(c => c.name === "mysql" && !c.skip) as MysqlConnectionOptions;
if (mysqlConfig) {
const {
username,
password,
host,
port,
database
} = mysqlConfig;
const url = `mysql://${username}:${password}@${host}:${port}/${database}`
const connection = await createConnection({
name: "#2096",
url: "mysql://root:admin@localhost:3306/test",
url,
entities: [__dirname + "/entity/*{.js,.ts}"],
synchronize: true,
type: "mysql"