Skip to content

Commit

Permalink
test(drill): more improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mateonunez committed Mar 1, 2023
1 parent 77170f7 commit 9b5c691
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
8 changes: 4 additions & 4 deletions packages/drill/test/database.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import { database } from '@mateonunez/asterism-huston'
const { mysqlOptions, postgresOptions } = database

test('should generate correctly the connection string', ({ end }) => {
test('mysql', async ({ same }) => {
test('mysql', async ({ equal }) => {
const { mysql } = generateConnectionString(mysqlOptions)
same(mysql, 'mysql://root:toor@127.0.0.1:3306/db')
equal(mysql, 'mysql://root:toor@127.0.0.1:3306/db')
})

test('postgres', async ({ same }) => {
test('postgres', async ({ equal }) => {
const { postgres } = generateConnectionString(postgresOptions)
same(postgres, 'postgres://postgres:toor@127.0.0.1:5432/db')
equal(postgres, 'postgres://postgres:toor@127.0.0.1:5432/db')
})

end()
Expand Down
16 changes: 4 additions & 12 deletions packages/drill/test/errors.test.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,10 @@
import { test } from 'tap'
import setupDatabase from '../drill.js'

test('should throw an error when the database is not support', async ({ ok }) => {
try {
await setupDatabase(null, 'oracle', {})
} catch (err) {
ok(err)
}
test('should throw an error when the database is not support', async ({ rejects }) => {
await rejects(setupDatabase(null, 'fake', {}), 'Database not supported')
})

test('should throw an error when the parameters are wront', async ({ ok }) => {
try {
await setupDatabase(null, 'mysql', { user: 'fake', password: 'kaboom' })
} catch (err) {
ok(err)
}
test('should throw an error when the parameters are wront', async ({ rejects }) => {
await rejects(setupDatabase(null, 'mysql', { user: 'fake', password: 'kaboom' }), 'Error connecting to database')
})

0 comments on commit 9b5c691

Please sign in to comment.