Skip to content

Commit

Permalink
improved test to be more like an actual scenario
Browse files Browse the repository at this point in the history
  • Loading branch information
MZanggl committed Oct 22, 2019
1 parent 1cd7146 commit f8486a4
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions test/unit/database.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,11 @@ test.group('Database | QueryBuilder', (group) => {

test('create nested transaction (savepoint) when global transaction is in place', async (assert) => {
await this.database.beginGlobalTransaction()
await this.database.table('users').insert({ username: 'michael' })
const trx = await this.database.beginTransaction()
await trx.table('users').where({ username: 'michael' }).update({ username: 'virk' })
await this.database.commitGlobalTransaction()
const firstUser = await this.database.table('users').first()
assert.equal(firstUser.username, 'virk')
await this.database.table('users').insert({ username: 'michael' }, trx)
await trx.commit()
await this.database.rollbackGlobalTransaction()
assert.isUndefined(await this.database.table('users').first())
})

test('destroy database connection', async (assert) => {
Expand Down

0 comments on commit f8486a4

Please sign in to comment.