Skip to content
This repository has been archived by the owner on Jun 11, 2024. It is now read-only.

Commit

Permalink
Applied suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
vardan10 committed Oct 19, 2023
1 parent 9702972 commit cb90ac6
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions framework/tests/functional/database/mysql/mysql.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,8 @@ describe('Test MySQL', () => {
});

describe('With IMPLICIT DB transaction (auto-commit mode)', () => {
afterAll(() => blocksTable.rawQuery(`TRUNCATE ${tableName}`));

afterEach(async () => {
blocksTable.rawQuery(`DELETE FROM ${tableName}`);
await blocksTable.rawQuery(`TRUNCATE ${tableName}`);
});

it('should insert row', async () => {
Expand Down Expand Up @@ -217,6 +215,7 @@ describe('Test MySQL', () => {
});

it('should get row count', async () => {
await blocksTable.upsert([emptyBlock, nonEmptyBlock]);
const count = await blocksTable.count();
expect(count).toBe(2);
});
Expand Down Expand Up @@ -749,10 +748,8 @@ describe('Test MySQL', () => {
});

describe('With EXPLICIT DB transaction (non-auto commit mode)', () => {
afterAll(() => blocksTable.rawQuery(`TRUNCATE ${tableName}`));

afterEach(async () => {
blocksTable.rawQuery(`DELETE FROM ${tableName}`);
await blocksTable.rawQuery(`TRUNCATE ${tableName}`);
});

it('should insert row', async () => {
Expand All @@ -766,6 +763,11 @@ describe('Test MySQL', () => {
});

it('should get rows', async () => {
const connection = await getDBConnection();
const trx = await startDBTransaction(connection);
await blocksTable.upsert([emptyBlock], trx);
await commitDBTransaction(trx);

const result = await blocksTable.find({ id: emptyBlock.id }, ['id']);
expect(result).toBeInstanceOf(Array);
expect(result.length).toBe(1);
Expand Down Expand Up @@ -933,6 +935,11 @@ describe('Test MySQL', () => {
});

it('should get row count', async () => {
const connection = await getDBConnection();
const trx = await startDBTransaction(connection);
await blocksTable.upsert([emptyBlock, nonEmptyBlock], trx);
await commitDBTransaction(trx);

const count = await blocksTable.count();
expect(count).toBe(2);
});
Expand Down Expand Up @@ -1401,7 +1408,7 @@ describe('Test MySQL', () => {

describe('Transactional atomicity guarantees (non-auto commit mode)', () => {
afterEach(async () => {
blocksTable.rawQuery(`DELETE FROM ${tableName}`);
await blocksTable.rawQuery(`TRUNCATE ${tableName}`);
});

it('should perform a successful transaction commit', async () => {
Expand Down

0 comments on commit cb90ac6

Please sign in to comment.