fix tests

This commit is contained in:
Girish Ramakrishnan
2025-09-13 14:51:30 +02:00
parent 045187fe2d
commit 43cc91aca2
7 changed files with 28 additions and 12 deletions
+13 -5
View File
@@ -223,6 +223,12 @@ describe('Storage', function () {
expect(cfg.region).to.be(backupConfig.region);
}
async headObject(params) {
expect(params.Bucket).to.be(backupConfig.bucket);
const stat = await fs.promises.stat(path.join(bucketPathNoPrefix, params.Key));
return { ContentLength: stat.size };
}
async listObjectsV2(params) {
expect(params.Bucket).to.be(backupConfig.bucket);
return {
@@ -238,10 +244,12 @@ describe('Storage', function () {
async copyObject(params) {
// CopySource already has the bucket path!
const source = path.join(basePath, params.CopySource.replace(/%2B/g, '+'));
// Key already has prefix but no bucket ptah!
console.log('Copying:', path.join(basePath, params.CopySource), path.join(bucketPathNoPrefix, params.Key));
await fs.promises.mkdir(path.dirname(path.join(bucketPathNoPrefix, params.Key)), { recursive: true });
await fs.promises.copyFile(path.join(basePath, params.CopySource.replace(/%2B/g, '+')), path.join(bucketPathNoPrefix, params.Key));
const dest = path.join(bucketPathNoPrefix, params.Key);
console.log('Copying:', source, dest, path.dirname(dest));
await fs.promises.mkdir(path.dirname(dest), { recursive: true });
await fs.promises.copyFile(source, dest);
}
async deleteObject(params) {
@@ -301,7 +309,7 @@ describe('Storage', function () {
it('can copy', async function () {
fs.writeFileSync(path.join(bucketPath, 'uploadtest/C++.gitignore'), 'special', 'utf8');
await s3.copy(backupConfig, 'uploadtest', 'uploadtest-copy', () => {});
await s3.copyDir(backupConfig, 'uploadtest', 'uploadtest-copy', () => {});
const sourceFile = path.join(__dirname, 'storage/data/test.txt');
expect(fs.statSync(path.join(bucketPath, 'uploadtest-copy/test.txt')).size).to.be(fs.statSync(sourceFile).size);
expect(fs.statSync(path.join(bucketPath, 'uploadtest-copy/C++.gitignore')).size).to.be(7);
@@ -438,7 +446,7 @@ describe('Storage', function () {
it('can copy', async function () {
fs.writeFileSync(path.join(bucketPath, 'uploadtest/C++.gitignore'), 'special', 'utf8');
await gcs.copy(backupConfig, 'uploadtest', 'uploadtest-copy', () => {});
await gcs.copyDir(backupConfig, 'uploadtest', 'uploadtest-copy', () => {});
const sourceFile = path.join(__dirname, 'storage/data/test.txt');
expect(fs.statSync(path.join(bucketPath, 'uploadtest-copy/test.txt')).size).to.be(fs.statSync(sourceFile).size);
expect(fs.statSync(path.join(bucketPath, 'uploadtest-copy/C++.gitignore')).size).to.be(7);