From 33041ccde5e46b95e1d10b1a15ad798b3a972651 Mon Sep 17 00:00:00 2001 From: James Ward Date: Sun, 2 Aug 2020 10:36:32 -0400 Subject: [PATCH] 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 --- test/github-issues/114/issue-114.ts | 2 +- test/github-issues/2096/issue-2096.ts | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/test/github-issues/114/issue-114.ts b/test/github-issues/114/issue-114.ts index 0bf45946e2..f3a322fb5c 100644 --- a/test/github-issues/114/issue-114.ts +++ b/test/github-issues/114/issue-114.ts @@ -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", }); diff --git a/test/github-issues/2096/issue-2096.ts b/test/github-issues/2096/issue-2096.ts index 05cbfc11bb..768f48b17b 100644 --- a/test/github-issues/2096/issue-2096.ts +++ b/test/github-issues/2096/issue-2096.ts @@ -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"