/
command.ts
36 lines (30 loc) · 1.45 KB
/
command.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import "reflect-metadata";
import {createTestingConnections, closeTestingConnections, /*reloadTestingDatabases*/} from "../../../utils/test-utils";
import {Connection} from "../../../../src/connection/Connection";
import { Category, Post } from "./entity";
describe("migrations > generate command", () => {
let connections: Connection[];
before(async () => connections = await createTestingConnections({
migrations: [],
enabledDrivers: ["postgres"],
schemaCreate: false,
dropSchema: true,
entities: [Post, Category],
logging: true,
schema: "public",
}));
// beforeEach(() => reloadTestingDatabases(connections));
after(() => closeTestingConnections(connections));
it("can recognize model changes", () => Promise.all(connections.map(async connection => {
const sqlInMemory = await connection.driver.createSchemaBuilder().log();
sqlInMemory.upQueries.length.should.be.greaterThan(0);
sqlInMemory.downQueries.length.should.be.greaterThan(0);
})));
it("does not generate when no model changes", () => Promise.all(connections.map(async connection => {
await connection.driver.createSchemaBuilder().build();
const sqlInMemory = await connection.driver.createSchemaBuilder().log();
console.log(sqlInMemory.upQueries);
sqlInMemory.upQueries.length.should.be.equal(0);
sqlInMemory.downQueries.length.should.be.equal(0);
})));
});