Skip to content

Commit e7d078a

Browse files
Fix E2E tests: session used after being closed (#133)
Signed-off-by: Levko Kravets <levko.ne@gmail.com>
1 parent 7ac6755 commit e7d078a

File tree

3 files changed

+18
-16
lines changed

3 files changed

+18
-16
lines changed

tests/e2e/arrow.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ describe('Arrow support', () => {
5858
await testBody(session);
5959
} catch (error) {
6060
logger(error);
61-
await session.close();
6261
throw error;
6362
} finally {
6463
await deleteTable(session, tableName);
64+
await session.close();
6565
}
6666
};
6767
}

tests/e2e/batched_fetch.test.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,15 +36,23 @@ describe('Data fetching', () => {
3636

3737
it('fetch chunks should return a max row set of chunkSize', async () => {
3838
const session = await openSession();
39-
const operation = await session.executeStatement(query, { runAsync: true, maxRows: null });
40-
let chunkedOp = await operation.fetchChunk({ maxRows: 10 }).catch((error) => logger(error));
41-
expect(chunkedOp.length).to.be.equal(10);
39+
try {
40+
const operation = await session.executeStatement(query, { runAsync: true, maxRows: null });
41+
let chunkedOp = await operation.fetchChunk({ maxRows: 10 }).catch((error) => logger(error));
42+
expect(chunkedOp.length).to.be.equal(10);
43+
} finally {
44+
await session.close();
45+
}
4246
});
4347

4448
it('fetch all should fetch all records', async () => {
4549
const session = await openSession();
46-
const operation = await session.executeStatement(query, { runAsync: true, maxRows: null });
47-
let all = await operation.fetchAll();
48-
expect(all.length).to.be.equal(1000);
50+
try {
51+
const operation = await session.executeStatement(query, { runAsync: true, maxRows: null });
52+
let all = await operation.fetchAll();
53+
expect(all.length).to.be.equal(1000);
54+
} finally {
55+
await session.close();
56+
}
4957
});
5058
});

tests/e2e/data_types.test.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -189,14 +189,12 @@ describe('Data types', () => {
189189
dat: '2014-01-17',
190190
},
191191
]);
192-
193-
await session.close();
194192
} catch (error) {
195193
logger(error);
196-
await session.close();
197194
throw error;
198195
} finally {
199196
await execute(session, `DROP TABLE IF EXISTS ${table}`);
197+
await session.close();
200198
}
201199
});
202200

@@ -235,14 +233,12 @@ describe('Data types', () => {
235233
month_interval: '0-1',
236234
},
237235
]);
238-
239-
await session.close();
240236
} catch (error) {
241237
logger(error);
242-
await session.close();
243238
throw error;
244239
} finally {
245240
await execute(session, `DROP TABLE IF EXISTS ${table}`);
241+
await session.close();
246242
}
247243
});
248244

@@ -362,15 +358,13 @@ describe('Data types', () => {
362358
},
363359
},
364360
]);
365-
366-
await session.close();
367361
} catch (error) {
368362
logger(error);
369-
await session.close();
370363
throw error;
371364
} finally {
372365
await execute(session, `DROP TABLE IF EXISTS ${table}`);
373366
await execute(session, `DROP TABLE IF EXISTS ${helperTable}`);
367+
await session.close();
374368
}
375369
});
376370
});

0 commit comments

Comments
 (0)