Skip to content

Commit

Permalink
test: disable test for typeorm#4753 if no MySQL is present in ormconf…
Browse files Browse the repository at this point in the history
…ig.json
  • Loading branch information
Ginden committed Mar 23, 2022
1 parent e5c9582 commit 93e9e71
Showing 1 changed file with 30 additions and 8 deletions.
38 changes: 30 additions & 8 deletions test/github-issues/4753/issue-4753.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,53 @@
import { getConnectionManager } from "../../../src"
import { DataSource } from "../../../src/data-source/DataSource"
import { closeTestingConnections } from "../../utils/test-utils"
import { MysqlConnectionOptions } from "../../../src/driver/mysql/MysqlConnectionOptions"
import {
closeTestingConnections,
getTypeOrmConfig,
TestingConnectionOptions,
} from "../../utils/test-utils"
import { User } from "./entity/User"

function isMySql(v: TestingConnectionOptions): v is MysqlConnectionOptions {
return v.type === "mysql"
}

describe("github issues > #4753 MySQL Replication Config broken", () => {
let connections: DataSource[] = []
after(() => closeTestingConnections(connections))

it("should connect without error when using replication", async () => {
const connection = getConnectionManager().create({
const connectionOptions: MysqlConnectionOptions | undefined =
getTypeOrmConfig()
.filter((v) => !v.skip)
.find(isMySql)

if (!connectionOptions) {
// Skip if MySQL tests aren't enabled at all
return
}
const connectionManager = getConnectionManager()
const connection = connectionManager.create({
type: "mysql",
replication: {
master: {
username: "test",
password: "test",
database: "test",
host: connectionOptions.host,
username: connectionOptions.username,
password: connectionOptions.password,
database: connectionOptions.database,
},
slaves: [
{
username: "test",
password: "test",
database: "test",
host: connectionOptions.host,
username: connectionOptions.username,
password: connectionOptions.password,
database: connectionOptions.database,
},
],
},
entities: [User],
})

connections.push(connection)
await connection.connect()
connection.isInitialized.should.be.true
Expand Down

0 comments on commit 93e9e71

Please sign in to comment.