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 22, 2022
1 parent 53e4383 commit d692e7c
Showing 1 changed file with 26 additions and 8 deletions.
34 changes: 26 additions & 8 deletions test/github-issues/4753/issue-4753.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,49 @@
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().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",
username: connectionOptions.username,
password: connectionOptions.password,
database: connectionOptions.database,
},
slaves: [
{
username: "test",
password: "test",
database: "test",
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 d692e7c

Please sign in to comment.