From d32f9f08646ba047abad867d4fb935817c97c0f2 Mon Sep 17 00:00:00 2001 From: Harminder virk Date: Mon, 30 Sep 2019 23:17:10 +0530 Subject: [PATCH] test: fix breaking tests --- test-helpers/index.ts | 1 + test/database/query-client.spec.ts | 18 +++++++++++++++++- test/orm/adapter.spec.ts | 4 ++-- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/test-helpers/index.ts b/test-helpers/index.ts index 1e30bdbc..bf23227f 100644 --- a/test-helpers/index.ts +++ b/test-helpers/index.ts @@ -152,6 +152,7 @@ export async function resetTables () { await db.table('users').truncate() await db.table('profiles').truncate() await db.table('identities').truncate() + await db.destroy() } /** diff --git a/test/database/query-client.spec.ts b/test/database/query-client.spec.ts index 2a201497..6418a4ee 100644 --- a/test/database/query-client.spec.ts +++ b/test/database/query-client.spec.ts @@ -12,7 +12,7 @@ import test from 'japa' import { Connection } from '../../src/Connection' import { QueryClient } from '../../src/QueryClient' -import { getConfig, setup, cleanup, getLogger } from '../../test-helpers' +import { getConfig, setup, cleanup, getLogger, resetTables } from '../../test-helpers' test.group('Query client', (group) => { group.before(async () => { @@ -23,6 +23,10 @@ test.group('Query client', (group) => { await cleanup() }) + group.afterEach(async () => { + await resetTables() + }) + test('get query client in dual mode', async (assert) => { const connection = new Connection('primary', getConfig(), getLogger()) connection.connect() @@ -60,6 +64,10 @@ test.group('Query client | dual mode', (group) => { await cleanup() }) + group.afterEach(async () => { + await resetTables() + }) + test('perform select queries in dual mode', async (assert) => { const connection = new Connection('primary', getConfig(), getLogger()) connection.connect() @@ -131,6 +139,10 @@ test.group('Query client | read mode', (group) => { await cleanup() }) + group.afterEach(async () => { + await resetTables() + }) + test('perform select queries in read mode', async (assert) => { const connection = new Connection('primary', getConfig(), getLogger()) connection.connect() @@ -194,6 +206,10 @@ test.group('Query client | write mode', (group) => { await cleanup() }) + group.afterEach(async () => { + await resetTables() + }) + test('perform select queries in write mode', async (assert) => { const connection = new Connection('primary', getConfig(), getLogger()) connection.connect() diff --git a/test/orm/adapter.spec.ts b/test/orm/adapter.spec.ts index 64fe796a..3df04003 100644 --- a/test/orm/adapter.spec.ts +++ b/test/orm/adapter.spec.ts @@ -140,7 +140,7 @@ test.group('Adapter', (group) => { assert.isFalse(users[0].$isDirty) assert.isFalse(users[1].$isDirty) - assert.deepEqual(users[0].$attributes, { id: 1, username: 'virk' }) - assert.deepEqual(users[1].$attributes, { id: 2, username: 'nikk' }) + assert.deepEqual(users[0].$attributes, { id: 2, username: 'nikk' }) + assert.deepEqual(users[1].$attributes, { id: 1, username: 'virk' }) }) })