Compare commits

...

3 Commits

Author SHA1 Message Date
Lauren Spiegel 0561a89cd3 Revert dependency 2016-10-31 10:47:30 -07:00
alexandremerle eb14f7f767 FIX: Add non regression test
add non regression test
2016-10-29 22:43:43 +02:00
alexandremerle aa5b29e8dd FIX: Set readysetstream as scality dependency
Update readysetstream with the new scality repository
2016-10-29 21:43:34 +02:00
1 changed files with 31 additions and 1 deletions

View File

@ -1,10 +1,12 @@
import assert from 'assert'; import assert from 'assert';
import httpMocks from 'node-mocks-http'; import httpMocks from 'node-mocks-http';
import { EventEmitter } from 'events'; import { EventEmitter } from 'events';
import { errors } from 'arsenal';
import { cleanup, DummyRequestLogger } from '../helpers'; import { cleanup, DummyRequestLogger } from '../helpers';
import { ds } from '../../../lib/data/in_memory/backend'; import { ds } from '../../../lib/data/in_memory/backend';
import routesUtils from '../../../lib/routes/routesUtils'; import routesUtils from '../../../lib/routes/routesUtils';
import data from '../../../lib/data/wrapper';
const responseStreamData = routesUtils.responseStreamData; const responseStreamData = routesUtils.responseStreamData;
const log = new DummyRequestLogger(); const log = new DummyRequestLogger();
@ -24,7 +26,7 @@ const dataStoreEntry = {
}, },
}; };
describe('responseStreamData function', () => { describe('responseStreamData:', () => {
beforeEach(() => { beforeEach(() => {
cleanup(); cleanup();
}); });
@ -74,4 +76,32 @@ describe('responseStreamData function', () => {
return responseStreamData(errCode, overrideHeaders, return responseStreamData(errCode, overrideHeaders,
resHeaders, dataLocations, response, null, log); resHeaders, dataLocations, response, null, log);
}); });
it('#334 non-regression test, destroy connection on error', done => {
const dataLocations = [{
key: 1,
dataStore: 'mem',
start: 0,
size: 11,
}];
const prev = data.get;
data.get = (objectGetInfo, log, cb) => {
setTimeout(() => cb(errors.InternalError), 1000);
};
const response = httpMocks.createResponse({
eventEmitter: EventEmitter,
});
response.connection = {
destroy: () => {
data.get = prev;
done();
},
};
response.on('end', () => {
data.get = prev;
done(new Error('end reached instead of destroying connection'));
});
return responseStreamData(errCode, overrideHeaders,
resHeaders, dataLocations, response, null, log);
});
}); });