From 7b33347b4ccbb75268f5b540e153fb71423d8330 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Fri, 12 Nov 2021 18:04:08 +0100 Subject: [PATCH] fix(core): update --- test/test.easystore.ts | 12 +++++------- test/test.ts | 15 +++++---------- test/test.typescript.ts | 15 +++++---------- 3 files changed, 15 insertions(+), 27 deletions(-) diff --git a/test/test.easystore.ts b/test/test.easystore.ts index d244d22..500ec49 100644 --- a/test/test.easystore.ts +++ b/test/test.easystore.ts @@ -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(); diff --git a/test/test.ts b/test/test.ts index eda489c..edee040 100644 --- a/test/test.ts +++ b/test/test.ts @@ -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 }); diff --git a/test/test.typescript.ts b/test/test.typescript.ts index 0e3ada8..b3ea0bd 100644 --- a/test/test.typescript.ts +++ b/test/test.typescript.ts @@ -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 });