Dominik Schwank
8d160cefb0
During a delete the metadata file is updated. As the overwrite property was not set, the metadata couldn't be updated and caused issues.
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import { expect, expectAsync, tap } from '@push.rocks/tapbundle';
|
|
import { Qenv } from '@push.rocks/qenv';
|
|
|
|
import * as smartbucket from '../ts/index.js';
|
|
|
|
const testQenv = new Qenv('./', './.nogit/');
|
|
|
|
let testSmartbucket: smartbucket.SmartBucket;
|
|
let myBucket: smartbucket.Bucket;
|
|
let baseDirectory: smartbucket.Directory;
|
|
|
|
tap.test('should create a valid smartbucket', async () => {
|
|
testSmartbucket = new smartbucket.SmartBucket({
|
|
accessKey: await testQenv.getEnvVarOnDemand('S3_KEY'),
|
|
accessSecret: await testQenv.getEnvVarOnDemand('S3_SECRET'),
|
|
endpoint: await testQenv.getEnvVarOnDemand('S3_ENDPOINT'),
|
|
});
|
|
expect(testSmartbucket).toBeInstanceOf(smartbucket.SmartBucket);
|
|
myBucket = await testSmartbucket.getBucketByName('testzone');
|
|
expect(myBucket).toBeInstanceOf(smartbucket.Bucket);
|
|
expect(myBucket.name).toEqual('testzone');
|
|
});
|
|
|
|
tap.test('should put a file into the trash', async () => {
|
|
const path = 'hithere/socool.txt';
|
|
const file = await myBucket.fastPut({
|
|
path,
|
|
contents: 'hi there!',
|
|
});
|
|
expect(await file.getMetaData().then((meta) => meta.metadataFile.getJsonData())).toEqual({});
|
|
await file.delete({ mode: 'trash' });
|
|
expect(await file.getMetaData().then((meta) => meta.metadataFile.getJsonData())).toEqual({
|
|
custom_recycle: {
|
|
deletedAt: 123,
|
|
originalPath: 'hithere/socool.txt',
|
|
},
|
|
});
|
|
});
|
|
|
|
export default tap.start();
|