fix(core): update

This commit is contained in:
2022-05-17 21:26:17 +02:00
parent a739582861
commit 355a2a3f2b
10 changed files with 604 additions and 524 deletions

View File

@ -45,12 +45,11 @@ tap.test('should create an easystore', async () => {
});
tap.test('close', async () => {
await testDb.mongoDb.dropDatabase();
await testDb.close();
if (smartmongoInstance) {
await smartmongoInstance.stop();
} else {
await testDb.mongoDb.dropDatabase();
}
await testDb.close();
});
tap.start();

View File

@ -205,12 +205,11 @@ tap.test('should use a cursor', async () => {
// close the database connection
// =======================================
tap.test('close', async () => {
await testDb.mongoDb.dropDatabase();
await testDb.close();
if (smartmongoInstance) {
await smartmongoInstance.stop();
} else {
await testDb.mongoDb.dropDatabase();
}
await testDb.close();
});
tap.start({ throwOnError: true });

View File

@ -85,12 +85,11 @@ tap.test('should get a car', async () => {
// close the database connection
// =======================================
tap.test('close', async () => {
await testDb.mongoDb.dropDatabase();
await testDb.close();
if (smartmongoInstance) {
await smartmongoInstance.stop();
} else {
await testDb.mongoDb.dropDatabase();
}
await testDb.close();
});
tap.start({ throwOnError: true });

View File

@ -19,14 +19,26 @@ let testDb: smartdata.SmartdataDb;
const totalCars = 2000;
tap.test('should create a testinstance as database', async () => {
tap.skip.test('should create a testinstance as database', async () => {
smartmongoInstance = await smartmongo.SmartMongo.createAndStart();
testDb = new smartdata.SmartdataDb(await smartmongoInstance.getMongoDescriptor());
await testDb.init();
});
tap.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();
});
@smartdata.Collection(() => testDb)
class House extends smartdata.SmartDataDbDoc<House, House> {
@smartdata.unI()
public id: string = smartunique.shortId();
@smartdata.svDb()
public data = {
id: smartunique.shortId(),
@ -34,16 +46,17 @@ class House extends smartdata.SmartDataDbDoc<House, House> {
}
}
tap.skip.test('should watch a collection', async (toolsArg) => {
tap.test('should watch a collection', async (toolsArg) => {
const done = toolsArg.defer();
const watcher = await House.watch({});
watcher.changeSubject.subscribe(houseArg => {
watcher.changeSubject.subscribe(async houseArg => {
console.log('hey there, we observed a house');
watcher.close();
await watcher.close();
done.resolve();
});
const newHouse = new House();
await newHouse.save();
console.log('saved a house');
await done.promise;
})
@ -51,12 +64,11 @@ tap.skip.test('should watch a collection', async (toolsArg) => {
// close the database connection
// =======================================
tap.test('close', async () => {
await testDb.mongoDb.dropDatabase();
await testDb.close();
if (smartmongoInstance) {
await smartmongoInstance.stop();
} else {
await testDb.mongoDb.dropDatabase();
}
await testDb.close();
});
tap.start({ throwOnError: true });