40 lines
1.4 KiB
TypeScript
40 lines
1.4 KiB
TypeScript
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
|
import * as smartmongo from '@push.rocks/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 dump a collection to a directory', async () => {
|
|
const target = await testMongodump.addMongoTargetByMongoDescriptor(await testSmartMongo.getMongoDescriptor());
|
|
await target.dumpAllCollectionsToDir('.nogit', docArg => docArg.id, true);
|
|
})
|
|
|
|
tap.test('should stop the smartmongo instance', async () => {
|
|
await sampledata.stop();
|
|
await testMongodump.stop();
|
|
await testSmartMongo.stop();
|
|
});
|
|
|
|
export default tap.start();
|