Skip to content

Commit f8e29bd

Browse files
author
Gonçalo Alves
committed
move MySQL-specific closure-table tests to a separate file
1 parent 4c2ad94 commit f8e29bd

File tree

2 files changed

+135
-128
lines changed

2 files changed

+135
-128
lines changed
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
import "reflect-metadata"
2+
import { Foo1Entity } from "./entity/Foo1"
3+
import { Foo2Entity } from "./entity/Foo2"
4+
import { Foo3Entity } from "./entity/Foo3"
5+
import { DataSource } from "../../../../src/data-source/DataSource"
6+
import {
7+
closeTestingConnections,
8+
createTestingConnections,
9+
reloadTestingDatabases,
10+
} from "../../../utils/test-utils"
11+
import { expect } from "chai"
12+
13+
describe("mysql > tree tables > closure-table", () => {
14+
let connections: DataSource[]
15+
before(
16+
async () =>
17+
(connections = await createTestingConnections({
18+
entities: [Foo1Entity, Foo2Entity, Foo3Entity],
19+
enabledDrivers: ["mysql"],
20+
})),
21+
)
22+
beforeEach(() => reloadTestingDatabases(connections))
23+
after(() => closeTestingConnections(connections))
24+
25+
it("foo1 should create closure columns unsigned", () =>
26+
Promise.all(
27+
connections.map(async (dataSource) => {
28+
const fooMetadata = dataSource.entityMetadatas.find(
29+
(el) => el.tableName === "foo1",
30+
)!
31+
32+
expect(fooMetadata).to.exist
33+
34+
const fooClosureMetadata = dataSource.entityMetadatas.find(
35+
(el) => el.tableName === "foo1_closure",
36+
)!
37+
38+
expect(fooClosureMetadata).to.exist
39+
40+
const ancestorCol = fooClosureMetadata.columns.find(
41+
(col) => col.databaseName === "ancestor_id",
42+
)!
43+
44+
expect(ancestorCol).to.exist
45+
46+
const descendantCol = fooClosureMetadata.columns.find(
47+
(col) => col.databaseName === "descendant_id",
48+
)!
49+
50+
expect(descendantCol).to.exist
51+
52+
expect(ancestorCol.unsigned).to.be.true
53+
expect(descendantCol.unsigned).to.be.true
54+
}),
55+
))
56+
57+
it("foo2 should create closure columns with specified zerofill, width, precision and scale", () =>
58+
Promise.all(
59+
connections.map(async (dataSource) => {
60+
const fooMetadata = dataSource.entityMetadatas.find(
61+
(el) => el.tableName === "foo2",
62+
)!
63+
64+
expect(fooMetadata).to.exist
65+
66+
const fooClosureMetadata = dataSource.entityMetadatas.find(
67+
(el) => el.tableName === "foo2_closure",
68+
)!
69+
70+
expect(fooClosureMetadata).to.exist
71+
72+
const ancestorCol = fooClosureMetadata.columns.find(
73+
(col) => col.databaseName === "ancestor_id",
74+
)!
75+
76+
expect(ancestorCol).to.exist
77+
78+
const descendantCol = fooClosureMetadata.columns.find(
79+
(col) => col.databaseName === "descendant_id",
80+
)!
81+
82+
expect(descendantCol).to.exist
83+
84+
expect(ancestorCol.zerofill).to.be.true
85+
expect(descendantCol.zerofill).to.be.true
86+
87+
expect(ancestorCol.width).to.be.eq(13)
88+
expect(descendantCol.width).to.be.eq(13)
89+
90+
expect(ancestorCol.precision).to.be.eq(9)
91+
expect(descendantCol.precision).to.be.eq(9)
92+
93+
expect(ancestorCol.scale).to.be.eq(3)
94+
expect(descendantCol.scale).to.be.eq(3)
95+
}),
96+
))
97+
98+
it("foo3 should create closure columns with specified length, charset and collation", () =>
99+
Promise.all(
100+
connections.map(async (dataSource) => {
101+
const fooMetadata = dataSource.entityMetadatas.find(
102+
(el) => el.tableName === "foo3",
103+
)!
104+
105+
expect(fooMetadata).to.exist
106+
107+
const fooClosureMetadata = dataSource.entityMetadatas.find(
108+
(el) => el.tableName === "foo3_closure",
109+
)!
110+
111+
expect(fooClosureMetadata).to.exist
112+
113+
const ancestorCol = fooClosureMetadata.columns.find(
114+
(col) => col.databaseName === "ancestor_id",
115+
)!
116+
117+
expect(ancestorCol).to.exist
118+
119+
const descendantCol = fooClosureMetadata.columns.find(
120+
(col) => col.databaseName === "descendant_id",
121+
)!
122+
123+
expect(descendantCol).to.exist
124+
125+
expect(ancestorCol.length).to.be.eq("201")
126+
expect(descendantCol.length).to.be.eq("201")
127+
128+
expect(ancestorCol.charset).to.be.eq("latin1")
129+
expect(descendantCol.charset).to.be.eq("latin1")
130+
131+
expect(ancestorCol.collation).to.be.eq("latin1_bin")
132+
expect(descendantCol.collation).to.be.eq("latin1_bin")
133+
}),
134+
))
135+
})

test/functional/tree-tables/closure-table/closure-table.ts

Lines changed: 0 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,11 @@
11
import "reflect-metadata"
22
import { Category } from "./entity/Category"
3-
import { Foo1Entity } from "./entity/Foo1"
4-
import { Foo2Entity } from "./entity/Foo2"
5-
import { Foo3Entity } from "./entity/Foo3"
63
import { DataSource } from "../../../../src/data-source/DataSource"
74
import {
85
closeTestingConnections,
96
createTestingConnections,
107
reloadTestingDatabases,
118
} from "../../../utils/test-utils"
12-
import { expect } from "chai"
139

1410
describe("tree tables > closure-table", () => {
1511
let connections: DataSource[]
@@ -733,127 +729,3 @@ describe("tree tables > closure-table", () => {
733729
}),
734730
))
735731
})
736-
737-
describe("mysql > tree tables > closure-table", () => {
738-
let connections: DataSource[]
739-
before(
740-
async () =>
741-
(connections = await createTestingConnections({
742-
entities: [Foo1Entity, Foo2Entity, Foo3Entity],
743-
enabledDrivers: ["mysql"],
744-
})),
745-
)
746-
beforeEach(() => reloadTestingDatabases(connections))
747-
after(() => closeTestingConnections(connections))
748-
749-
it("foo1 should create closure columns unsigned", () =>
750-
Promise.all(
751-
connections.map(async (dataSource) => {
752-
const fooMetadata = dataSource.entityMetadatas.find(
753-
(el) => el.tableName === "foo1",
754-
)!
755-
756-
expect(fooMetadata).to.exist
757-
758-
const fooClosureMetadata = dataSource.entityMetadatas.find(
759-
(el) => el.tableName === "foo1_closure",
760-
)!
761-
762-
expect(fooClosureMetadata).to.exist
763-
764-
const ancestorCol = fooClosureMetadata.columns.find(
765-
(col) => col.databaseName === "ancestor_id",
766-
)!
767-
768-
expect(ancestorCol).to.exist
769-
770-
const descendantCol = fooClosureMetadata.columns.find(
771-
(col) => col.databaseName === "descendant_id",
772-
)!
773-
774-
expect(descendantCol).to.exist
775-
776-
expect(ancestorCol.unsigned).to.be.true
777-
expect(descendantCol.unsigned).to.be.true
778-
}),
779-
))
780-
781-
it("foo2 should create closure columns with specified zerofill, width, precision and scale", () =>
782-
Promise.all(
783-
connections.map(async (dataSource) => {
784-
const fooMetadata = dataSource.entityMetadatas.find(
785-
(el) => el.tableName === "foo2",
786-
)!
787-
788-
expect(fooMetadata).to.exist
789-
790-
const fooClosureMetadata = dataSource.entityMetadatas.find(
791-
(el) => el.tableName === "foo2_closure",
792-
)!
793-
794-
expect(fooClosureMetadata).to.exist
795-
796-
const ancestorCol = fooClosureMetadata.columns.find(
797-
(col) => col.databaseName === "ancestor_id",
798-
)!
799-
800-
expect(ancestorCol).to.exist
801-
802-
const descendantCol = fooClosureMetadata.columns.find(
803-
(col) => col.databaseName === "descendant_id",
804-
)!
805-
806-
expect(descendantCol).to.exist
807-
808-
expect(ancestorCol.zerofill).to.be.true
809-
expect(descendantCol.zerofill).to.be.true
810-
811-
expect(ancestorCol.width).to.be.eq(13)
812-
expect(descendantCol.width).to.be.eq(13)
813-
814-
expect(ancestorCol.precision).to.be.eq(9)
815-
expect(descendantCol.precision).to.be.eq(9)
816-
817-
expect(ancestorCol.scale).to.be.eq(3)
818-
expect(descendantCol.scale).to.be.eq(3)
819-
}),
820-
))
821-
822-
it("foo3 should create closure columns with specified length, charset and collation", () =>
823-
Promise.all(
824-
connections.map(async (dataSource) => {
825-
const fooMetadata = dataSource.entityMetadatas.find(
826-
(el) => el.tableName === "foo3",
827-
)!
828-
829-
expect(fooMetadata).to.exist
830-
831-
const fooClosureMetadata = dataSource.entityMetadatas.find(
832-
(el) => el.tableName === "foo3_closure",
833-
)!
834-
835-
expect(fooClosureMetadata).to.exist
836-
837-
const ancestorCol = fooClosureMetadata.columns.find(
838-
(col) => col.databaseName === "ancestor_id",
839-
)!
840-
841-
expect(ancestorCol).to.exist
842-
843-
const descendantCol = fooClosureMetadata.columns.find(
844-
(col) => col.databaseName === "descendant_id",
845-
)!
846-
847-
expect(descendantCol).to.exist
848-
849-
expect(ancestorCol.length).to.be.eq("201")
850-
expect(descendantCol.length).to.be.eq("201")
851-
852-
expect(ancestorCol.charset).to.be.eq("latin1")
853-
expect(descendantCol.charset).to.be.eq("latin1")
854-
855-
expect(ancestorCol.collation).to.be.eq("latin1_bin")
856-
expect(descendantCol.collation).to.be.eq("latin1_bin")
857-
}),
858-
))
859-
})

0 commit comments

Comments
 (0)