fix(core): update

This commit is contained in:
Philipp Kunz 2021-11-12 18:04:08 +01:00
parent 3f11cbf595
commit 7b33347b4c
3 changed files with 15 additions and 27 deletions

View File

@ -19,7 +19,7 @@ let testDb: smartdata.SmartdataDb;
let smartdataOptions: smartdata.IMongoDescriptor;
let mongod: mongoPlugin.MongoMemoryServer;
tap.skip.test('should create a testinstance as database', async () => {
tap.test('should create a testinstance as database', async () => {
mongod = await mongoPlugin.MongoMemoryServer.create();
console.log('created mongod instance');
console.log('mongod started');
@ -31,12 +31,13 @@ tap.skip.test('should create a testinstance as database', async () => {
await testDb.init();
});
tap.test('should connect to atlas', async (tools) => {
tap.skip.test('should connect to atlas', async (tools) => {
const databaseName = `test-smartdata-${smartunique.shortId()}`;
testDb = new smartdata.SmartdataDb({
mongoDbUrl: testQenv.getEnvVarOnDemand('MONGO_URL'),
mongoDbName: databaseName,
});
await testDb.init();
});
let easyStore: smartdata.EasyStore<{
@ -52,11 +53,8 @@ tap.test('should create an easystore', async () => {
});
tap.test('close', async () => {
testDb.close();
mongod.stop();
setTimeout(() => {
process.exit(0);
}, 1000);
await mongod.stop();
await testDb.close();
});
tap.start();

View File

@ -21,7 +21,7 @@ let mongod: mongoPlugin.MongoMemoryServer;
const totalCars = 2000;
tap.skip.test('should create a testinstance as database', async () => {
tap.test('should create a testinstance as database', async () => {
mongod = await mongoPlugin.MongoMemoryServer.create();
console.log('created mongod instance');
console.log('mongod started');
@ -30,17 +30,15 @@ tap.skip.test('should create a testinstance as database', async () => {
};
console.log(smartdataOptions);
testDb = new smartdata.SmartdataDb(smartdataOptions);
await testDb.init();
});
tap.test('should connect to atlas', async (tools) => {
tap.skip.test('should connect to atlas', async (tools) => {
const databaseName = `test-smartdata-${smartunique.shortId()}`;
testDb = new smartdata.SmartdataDb({
mongoDbUrl: testQenv.getEnvVarOnDemand('MONGO_URL'),
mongoDbName: databaseName,
});
});
tap.test('should establish a connection to mongod', async () => {
await testDb.init();
});
@ -212,12 +210,9 @@ tap.test('should use a cursor', async () => {
// =======================================
// close the database connection
// =======================================
tap.test('should drop the db and close the database connection', async (tools) => {
await testDb.mongoDb.dropDatabase();
tap.test('close', async () => {
await mongod.stop();
await testDb.close();
try {
await mongod.stop();
} catch (e) {}
});
tap.start({ throwOnError: true });

View File

@ -21,7 +21,7 @@ let mongod: mongoPlugin.MongoMemoryServer;
const totalCars = 2000;
tap.skip.test('should create a testinstance as database', async () => {
tap.test('should create a testinstance as database', async () => {
mongod = await mongoPlugin.MongoMemoryServer.create();
console.log('created mongod instance');
console.log('mongod started');
@ -30,17 +30,15 @@ tap.skip.test('should create a testinstance as database', async () => {
};
console.log(smartdataOptions);
testDb = new smartdata.SmartdataDb(smartdataOptions);
await testDb.init();
});
tap.test('should connect to atlas', async (tools) => {
tap.skip.test('should connect to atlas', async (tools) => {
const databaseName = `test-smartdata-${smartunique.shortId()}`;
testDb = new smartdata.SmartdataDb({
mongoDbUrl: testQenv.getEnvVarOnDemand('MONGO_URL'),
mongoDbName: databaseName,
});
});
tap.test('should establish a connection to mongod', async () => {
await testDb.init();
});
@ -94,12 +92,9 @@ tap.test('should get a car', async () => {
// =======================================
// close the database connection
// =======================================
tap.test('should close the database connection', async (tools) => {
await testDb.mongoDb.dropDatabase();
tap.test('close', async () => {
await mongod.stop();
await testDb.close();
try {
await mongod.stop();
} catch (e) {}
});
tap.start({ throwOnError: true });