Skip to content

Commit

Permalink
test: fix agent lambda tests when run with nyc (elastic#505)
Browse files Browse the repository at this point in the history
This is a race condition. The tests would call t.end() before all
their assertions had finished. This would not be an issue when running
the tests normally, but when running via nyc it would fail.
  • Loading branch information
watson committed Oct 27, 2018
1 parent 5b472b5 commit 6d97d95
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions test/agent.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,8 @@ test('#lambda()', function (t) {
}

t.test('success - basic callback', function (t) {
t.plan(2 + assertTransaction.asserts + assertContext.asserts)

var name = 'greet.hello'
var input = { name: 'world' }
var output = 'Hello, world!'
Expand All @@ -621,7 +623,6 @@ test('#lambda()', function (t) {
lambda.invoke(name, input, (err, result) => {
t.error(err)
t.equal(result, output)
t.end()
})
})
.on('data-transaction', function (data) {
Expand All @@ -631,6 +632,8 @@ test('#lambda()', function (t) {
})

t.test('success - context.succeed', function (t) {
t.plan(2 + assertTransaction.asserts + assertContext.asserts)

var name = 'greet.hello'
var input = { name: 'world' }
var output = 'Hello, world!'
Expand All @@ -645,7 +648,6 @@ test('#lambda()', function (t) {
lambda.invoke(name, input, (err, result) => {
t.error(err)
t.equal(result, output)
t.end()
})
})
.on('data-transaction', function (data) {
Expand All @@ -655,6 +657,8 @@ test('#lambda()', function (t) {
})

t.test('success - context.done', function (t) {
t.plan(2 + assertTransaction.asserts + assertContext.asserts)

var name = 'greet.hello'
var input = { name: 'world' }
var output = 'Hello, world!'
Expand All @@ -669,7 +673,6 @@ test('#lambda()', function (t) {
lambda.invoke(name, input, (err, result) => {
t.error(err)
t.equal(result, output)
t.end()
})
})
.on('data-transaction', function (data) {
Expand Down

0 comments on commit 6d97d95

Please sign in to comment.