Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: invalid callback for client connect/upgrade #798

Merged
merged 3 commits into from May 10, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 12 additions & 1 deletion test/client-connect.js
Expand Up @@ -114,18 +114,29 @@ test('connect error', (t) => {
})

test('connect invalid opts', (t) => {
t.plan(2)
t.plan(6)

const client = new Client('http://localhost:5432')

client.connect(null, err => {
t.ok(err instanceof errors.InvalidArgumentError)
t.equal(err.message, 'invalid opts')
})

try {
client.connect(null, null)
t.fail()
} catch (err) {
t.ok(err instanceof errors.InvalidArgumentError)
t.equal(err.message, 'invalid opts')
}

try {
client.connect({ path: '/' }, null)
t.fail()
} catch (err) {
t.ok(err instanceof errors.InvalidArgumentError)
t.equal(err.message, 'invalid callback')
}
})

Expand Down
13 changes: 12 additions & 1 deletion test/client-upgrade.js
Expand Up @@ -146,18 +146,29 @@ test('upgrade error', (t) => {
})

test('upgrade invalid opts', (t) => {
t.plan(2)
t.plan(6)

const client = new Client('http://localhost:5432')

client.upgrade(null, err => {
t.ok(err instanceof errors.InvalidArgumentError)
t.equal(err.message, 'invalid opts')
})

try {
client.upgrade(null, null)
t.fail()
} catch (err) {
t.ok(err instanceof errors.InvalidArgumentError)
t.equal(err.message, 'invalid opts')
}

try {
client.upgrade({ path: '/' }, null)
t.fail()
} catch (err) {
t.ok(err instanceof errors.InvalidArgumentError)
t.equal(err.message, 'invalid callback')
}
})

Expand Down