smarts3/test/test.ts

31 lines
942 B
TypeScript

import { expect, tap } from '@push.rocks/tapbundle';
import * as plugins from './plugins.js';
import * as smarts3 from '../ts/index.js';
let testSmarts3Instance: smarts3.Smarts3;
tap.test('should create a smarts3 instance and run it', async (toolsArg) => {
testSmarts3Instance = await smarts3.Smarts3.createAndStart({
port: 3000,
cleanSlate: true,
});
console.log(`Let the instance run for 2 seconds`);
await toolsArg.delayFor(2000);
});
tap.test('should be able to access buckets', async () => {
const smartbucketInstance = new plugins.smartbucket.SmartBucket(
await testSmarts3Instance.getS3Descriptor(),
);
const bucket = await smartbucketInstance.createBucket('testbucket');
const baseDirectory = await bucket.getBaseDirectory();
await baseDirectory.fastStore('subdir/hello.txt', 'hi there!');
});
tap.test('should stop the instance', async () => {
await testSmarts3Instance.stop();
});
tap.start();