storage: make copy async
This commit is contained in:
@@ -139,16 +139,12 @@ describe('Storage', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('can copy', function (done) {
|
||||
it('can copy', async function () {
|
||||
const sourceFile = gTmpFolder + '/uploadtest/test.txt'; // keep the test within save device
|
||||
const destFile = gTmpFolder + '/uploadtest/test-hardlink.txt';
|
||||
|
||||
const events = filesystem.copy(gBackupConfig, sourceFile, destFile);
|
||||
events.on('done', function (error) {
|
||||
expect(error).to.be(null);
|
||||
expect(fs.statSync(destFile).nlink).to.be(2); // created a hardlink
|
||||
done();
|
||||
});
|
||||
await filesystem.copy(gBackupConfig, sourceFile, destFile, () => {});
|
||||
expect(fs.statSync(destFile).nlink).to.be(2); // created a hardlink
|
||||
});
|
||||
|
||||
it('can remove file', async function () {
|
||||
@@ -193,12 +189,8 @@ describe('Storage', function () {
|
||||
}, done);
|
||||
});
|
||||
|
||||
it('can copy', function (done) {
|
||||
const events = noop.copy(gBackupConfig, 'sourceFile', 'destFile');
|
||||
events.on('done', function (error) {
|
||||
expect(error).to.be(null);
|
||||
done();
|
||||
});
|
||||
it('can copy', async function () {
|
||||
await noop.copy(gBackupConfig, 'sourceFile', 'destFile', () => {});
|
||||
});
|
||||
|
||||
it('can remove file', async function () {
|
||||
@@ -269,21 +261,15 @@ describe('Storage', function () {
|
||||
});
|
||||
});
|
||||
|
||||
it('can copy', function (done) {
|
||||
it('can copy', async function () {
|
||||
fs.writeFileSync(path.join(gS3Folder, 'uploadtest/C++.gitignore'), 'special', 'utf8');
|
||||
|
||||
const sourceKey = 'uploadtest';
|
||||
|
||||
const events = s3.copy(gBackupConfig, sourceKey, 'uploadtest-copy');
|
||||
events.on('done', function (error) {
|
||||
const sourceFile = path.join(__dirname, 'storage/data/test.txt');
|
||||
expect(error).to.be(null);
|
||||
expect(fs.statSync(path.join(gS3Folder, 'uploadtest-copy/test.txt')).size).to.be(fs.statSync(sourceFile).size);
|
||||
|
||||
expect(fs.statSync(path.join(gS3Folder, 'uploadtest-copy/C++.gitignore')).size).to.be(7);
|
||||
|
||||
done();
|
||||
});
|
||||
await s3.copy(gBackupConfig, sourceKey, 'uploadtest-copy', () => {});
|
||||
const sourceFile = path.join(__dirname, 'storage/data/test.txt');
|
||||
expect(fs.statSync(path.join(gS3Folder, 'uploadtest-copy/test.txt')).size).to.be(fs.statSync(sourceFile).size);
|
||||
expect(fs.statSync(path.join(gS3Folder, 'uploadtest-copy/C++.gitignore')).size).to.be(7);
|
||||
});
|
||||
|
||||
xit('can remove file', async function () {
|
||||
|
||||
Reference in New Issue
Block a user