You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
616 B
28 lines
616 B
const { sync: rimrafSync } = require("rimraf");
|
|
const Database = require("../server/database");
|
|
|
|
class TestDB {
|
|
dataDir;
|
|
|
|
constructor(dir = "./data/test") {
|
|
this.dataDir = dir;
|
|
}
|
|
|
|
async create() {
|
|
Database.initDataDir({ "data-dir": this.dataDir });
|
|
Database.dbConfig = {
|
|
type: "sqlite",
|
|
};
|
|
Database.writeDBConfig(Database.dbConfig);
|
|
await Database.connect(true);
|
|
await Database.patch();
|
|
}
|
|
|
|
async destroy() {
|
|
await Database.close();
|
|
this.dataDir && rimrafSync(this.dataDir);
|
|
}
|
|
}
|
|
|
|
module.exports = TestDB;
|