use actual file size in dl progress. detect cancelled stream

This commit is contained in:
Danny Coates 2018-07-23 15:12:58 -07:00
parent 2afe79c941
commit 5483dc2506
No known key found for this signature in database
GPG key ID: 4C442633C62E00CB
6 changed files with 35 additions and 30 deletions

View file

@ -30,16 +30,15 @@ describe('/api/metadata', function() {
storage.length.reset();
});
it('calls storage.[ttl|length] with the id parameter', async function() {
it('calls storage.ttl with the id parameter', async function() {
const req = request('x');
const res = response();
await metadataRoute(req, res);
sinon.assert.calledWith(storage.ttl, 'x');
sinon.assert.calledWith(storage.length, 'x');
});
it('sends a 404 on failure', async function() {
storage.length.returns(Promise.reject(new Error()));
storage.ttl.returns(Promise.reject(new Error()));
const res = response();
await metadataRoute(request('x'), res);
sinon.assert.calledWith(res.sendStatus, 404);
@ -47,7 +46,6 @@ describe('/api/metadata', function() {
it('returns a json object', async function() {
storage.ttl.returns(Promise.resolve(123));
storage.length.returns(Promise.resolve(987));
const meta = {
dlimit: 1,
dl: 0,
@ -58,7 +56,6 @@ describe('/api/metadata', function() {
sinon.assert.calledWithMatch(res.send, {
metadata: 'foo',
finalDownload: true,
size: 987,
ttl: 123
});
});