smartbucket/test/test.ts
2019-10-16 18:12:18 +02:00

49 lines
1.4 KiB
TypeScript

import { expect, tap } from '@pushrocks/tapbundle';
import { Qenv } from '@pushrocks/qenv';
import * as smartbucket from '../ts/index';
const testQenv = new Qenv('./', './.nogit/');
let testSmartbucket: smartbucket.SmartBucket;
let myBucket: smartbucket.Bucket;
tap.test('should create a valid smartbucket', async () => {
testSmartbucket = new smartbucket.SmartBucket({
accessKey: testQenv.getEnvVarOnDemand('S3_KEY'),
accessSecret: testQenv.getEnvVarOnDemand('S3_SECRET'),
endpoint: 'ams3.digitaloceanspaces.com'
});
});
tap.skip.test('should create testbucket', async () => {
await testSmartbucket.createBucket('smartbucket');
});
tap.skip.test('should remove testbucket', async () => {
await testSmartbucket.removeBucket('pushrocks-smartbucket');
});
tap.test('should get a bucket', async () => {
myBucket = await testSmartbucket.getBucketByName('smartbucket');
expect(myBucket).to.be.instanceOf(smartbucket.Bucket);
expect(myBucket.name).to.equal('smartbucket');
});
// Fast operations
tap.test('should store data in bucket fast', async () => {
await myBucket.fastStore('hithere/socool.txt', 'hi there!');
});
tap.test('should get data in bucket', async () => {
const fileString = await myBucket.fastGet('hithere/socool.txt');
console.log(fileString);
});
tap.test('should delete data in bucket', async () => {
await myBucket.fastRemove('hithere/socool.txt');
});
tap.start();