fix(core): update

This commit is contained in:
2022-06-05 21:04:16 +02:00
commit fb0cf3ca64
18 changed files with 11474 additions and 0 deletions

32
test/sampledata.ts Normal file
View File

@ -0,0 +1,32 @@
import * as smartdata from '@pushrocks/smartdata';
let db: smartdata.SmartdataDb;
export const stop = async () => {
await db.close();
}
export const generateTestData = async (mongoDescriptorArg: smartdata.IMongoDescriptor) => {
db = new smartdata.SmartdataDb(mongoDescriptorArg);
await db.init();
let counter = 0;
@smartdata.Collection(db)
class House extends smartdata.SmartDataDbDoc<House, House> {
@smartdata.unI()
id = `hello-${counter}`;
@smartdata.svDb()
data = {
'some' : {
'complex': 'structure'
}
}
}
while (counter < 100) {
const house = new House();
await house.save();
counter++;
}
}

34
test/test.ts Normal file
View File

@ -0,0 +1,34 @@
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
import * as smartmongo from '@pushrocks/smartmongo';
import * as mongodump from '../ts/index.js';
import * as sampledata from './sampledata.js';
let testSmartMongo: smartmongo.SmartMongo;
let testMongodump: mongodump.MongoDump;
tap.test('should create a test database', async () => {
testSmartMongo = await smartmongo.SmartMongo.createAndStart();
});
tap.test('should create a mongodump instance', async () => {
testMongodump = new mongodump.MongoDump();
expect(testMongodump).toBeInstanceOf(mongodump.MongoDump);
});
tap.test('should deploy sample data', async () => {
await sampledata.generateTestData(await testSmartMongo.getMongoDescriptor())
})
tap.test('should add a mongotarget to mongodump instance', async () => {
const target = await testMongodump.addMongoTargetByMongoDescriptor(await testSmartMongo.getMongoDescriptor());
await target.getCollections();
})
tap.test('should stop the smartmongo instance', async () => {
await sampledata.stop();
await testMongodump.stop();
await testSmartMongo.stop();
});
tap.start();