-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.test.ts
30 lines (30 loc) · 1.06 KB
/
db.test.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
import "dotenv/config";
import "reflect-metadata";
import "source-map-support/register";
import * as assert from "assert";
import { Db } from "./db";
import { Foobar } from "./foobar";
import { Id } from "./id";
process.on("unhandledRejection", x => (console.error(x), process.exit(1)));
(async () => {
{
const id = Id();
await Db.createTestConnection();
let repository = Db.connection.getRepository(Foobar);
await repository.save({ createdAt: Date.now(), id });
await Db.createTestConnection();
repository = Db.connection.getRepository(Foobar);
const foobar = await repository.findOne(id);
assert(!foobar, "drops schema when creating test connection");
}
{
const id = Id();
await Db.createTestConnection();
let repository = Db.connection.getRepository(Foobar);
await repository.save({ createdAt: Date.now(), id });
await Db.createConnection();
repository = Db.connection.getRepository(Foobar);
const foobar = await repository.findOne(id);
assert(foobar, "creates regular connection without dropping schema");
}
})();