2024-10-26 12:14:41 +00:00
|
|
|
import { expect, tap } from '@push.rocks/tapbundle';
|
2022-04-14 08:36:24 +00:00
|
|
|
import * as plugins from './plugins.js';
|
2021-12-18 00:41:50 +00:00
|
|
|
|
2022-04-14 08:36:24 +00:00
|
|
|
import * as smarts3 from '../ts/index.js';
|
2021-12-18 00:41:50 +00:00
|
|
|
|
|
|
|
let testSmarts3Instance: smarts3.Smarts3;
|
|
|
|
|
2022-04-14 08:38:14 +00:00
|
|
|
tap.test('should create a smarts3 instance and run it', async (toolsArg) => {
|
2021-12-20 16:06:42 +00:00
|
|
|
testSmarts3Instance = await smarts3.Smarts3.createAndStart({
|
2021-12-18 00:41:50 +00:00
|
|
|
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 () => {
|
2022-04-14 08:38:14 +00:00
|
|
|
const smartbucketInstance = new plugins.smartbucket.SmartBucket(
|
2024-10-26 12:14:41 +00:00
|
|
|
await testSmarts3Instance.getS3Descriptor(),
|
2022-04-14 08:38:14 +00:00
|
|
|
);
|
2021-12-18 00:41:50 +00:00
|
|
|
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();
|
2022-04-14 08:38:14 +00:00
|
|
|
});
|
2021-12-18 00:41:50 +00:00
|
|
|
|
|
|
|
tap.start();
|