added test (issue #423)

This commit is contained in:
Zotov Dmitry 2018-02-22 17:16:31 +05:00
parent c5e3a27ac3
commit 06c2e46eb0
3 changed files with 47 additions and 1 deletions

View File

@ -344,7 +344,7 @@ export class Gulpfile {
.pipe(mocha({
bail: true,
grep: !!args.grep ? new RegExp(args.grep) : undefined,
timeout: 30000
timeout: 15000
}));
}

View File

@ -0,0 +1,16 @@
import {Entity} from "../../../../src/decorator/entity/Entity";
import {PrimaryColumn} from "../../../../src/decorator/columns/PrimaryColumn";
import {Column} from "../../../../src/decorator/columns/Column";
import {Index} from "../../../../src/decorator";
@Index("Groups name", ["name"], { unique: true })
@Entity("groups")
export class Group {
@PrimaryColumn()
id: number;
@Column()
name: string;
}

View File

@ -0,0 +1,30 @@
import "reflect-metadata";
import {closeTestingConnections, createTestingConnections} from "../../utils/test-utils";
import {Connection} from "../../../src/connection/Connection";
describe("github issues > #423 Cannot use Group as Table name && cannot autoSchemeSync when use alias Entity", () => {
let connections: Connection[];
before(async () => connections = await createTestingConnections({
entities: [__dirname + "/entity/*{.js,.ts}"],
schemaCreate: false,
dropSchema: true
}));
after(() => closeTestingConnections(connections));
it("should successfully sync schema", () => Promise.all(connections.map(async connection => {
await connection.synchronize();
const queryRunner = connection.createQueryRunner();
const table = await queryRunner.getTable("groups");
await queryRunner.release();
table!.should.exist;
table!.indices.length.should.be.equal(1);
table!.indices[0].name!.should.be.equal("Groups name");
table!.indices[0].columnNames[0].should.be.equal("name");
table!.indices[0].isUnique!.should.be.true;
})));
});