Merged 1.3.x_branch into master
This commit is contained in:
@@ -11,7 +11,6 @@ test(`construction fails if pool size is <= 1`, () => {
|
||||
});
|
||||
|
||||
test(`error on socket release is ignored`, async () => {
|
||||
|
||||
const conn = new connection_pool(2, '', 20000);
|
||||
let invoked = false;
|
||||
jest.spyOn(conn.pool, 'acquire').mockImplementation(() => {
|
||||
@@ -33,7 +32,7 @@ test(`error on socket release is ignored`, async () => {
|
||||
expect(invoked).toBeTruthy();
|
||||
});
|
||||
|
||||
test(`send fails if acquire fails`, async () => {
|
||||
test(`connection pool send fails if socket acquire fails`, async () => {
|
||||
const conn = new connection_pool(2, '', 20000);
|
||||
jest.spyOn(conn.pool, 'acquire').mockImplementation(() => {
|
||||
throw new Error('mock acquire exception');
|
||||
@@ -41,3 +40,21 @@ test(`send fails if acquire fails`, async () => {
|
||||
|
||||
await expect(conn.send('', new packet())).rejects.toThrow(Error);
|
||||
});
|
||||
|
||||
test(`connection pool send fails when connection send fails`, async () => {
|
||||
const conn = new connection_pool(2, '', 20000);
|
||||
jest.spyOn(conn.pool, 'acquire').mockImplementation(() => {
|
||||
return {
|
||||
release: () => {
|
||||
},
|
||||
}
|
||||
});
|
||||
|
||||
const mock_send = jest.fn();
|
||||
connection.prototype.send = async () => {
|
||||
return mock_send();
|
||||
};
|
||||
mock_send.mockRejectedValue(new Error('mock send failed'));
|
||||
|
||||
await expect(conn.send('', new packet())).rejects.toThrow(Error);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user