Display differential download size in UI

This commit is contained in:
Fedor Indutny 2022-02-25 10:44:03 -08:00 committed by GitHub
parent 052a8e65e2
commit 29c2f77d40
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 320 additions and 151 deletions

View file

@ -12,6 +12,7 @@ import {
computeDiff,
getBlockMapFileName,
prepareDownload,
isValidPreparedData,
download,
} from '../../updater/differential';
@ -143,6 +144,49 @@ describe('updater/differential', () => {
]);
});
it('checks that the data is valid to facilitate caching', async () => {
const oldFilePath = path.join(FIXTURES, oldFile);
const newUrl = `${baseUrl}/${newFile}`;
const data = await prepareDownload({
oldFile: oldFilePath,
newUrl,
sha512: newHash,
});
assert.isTrue(
isValidPreparedData(data, {
oldFile: oldFilePath,
newUrl,
sha512: newHash,
})
);
assert.isFalse(
isValidPreparedData(data, {
oldFile: 'different file',
newUrl,
sha512: newHash,
})
);
assert.isFalse(
isValidPreparedData(data, {
oldFile: oldFilePath,
newUrl: 'different url',
sha512: newHash,
})
);
assert.isFalse(
isValidPreparedData(data, {
oldFile: oldFilePath,
newUrl,
sha512: 'different hash',
})
);
});
it('downloads the file', async () => {
const data = await prepareDownload({
oldFile: path.join(FIXTURES, oldFile),