Skip to content

Commit

Permalink
fix: wrong test/assertion in test-trace-http (googleapis#615)
Browse files Browse the repository at this point in the history
The wrong test is 'should not trace api requests'. The header name to
check should be TRACE_AGENT_REQUEST_HEADER, not
TRACE_CONTEXT_HEADER_NAME. Also the assertion should be done against the
number of spans, not against the number of traces.

Also fix the order of arguments to `assert.equal()` calls. The first
argument must be the actual result and the second the expected value.
  • Loading branch information
jinwoo authored Nov 30, 2017
1 parent 2807a10 commit 582ed50
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions test/plugins/test-trace-http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('test-trace-http', function() {
res.on('data', function(data) { result += data; });
res.on('end', function() {
endTransaction();
assert.equal(common.serverRes, result);
assert.equal(result, common.serverRes);
common.assertDurationCorrect(Date.now() - start);
done();
});
Expand Down Expand Up @@ -95,13 +95,14 @@ describe('test-trace-http', function() {
server.listen(common.serverPort, common.runInTransaction.bind(null,
function(endTransaction) {
var headers = {};
headers[Constants.TRACE_CONTEXT_HEADER_NAME] = 'yay';
headers[Constants.TRACE_AGENT_REQUEST_HEADER] = 'yay';
http.get({port: common.serverPort, headers: headers});
setTimeout(function() {
endTransaction();
// The only trace present should be the outer transaction
var traces = common.getTraces();
assert.equal(traces.length, 1);
// The only span present should be the outer span.
assert.equal(traces[0].spans.length, 1);
assert.equal(traces[0].spans[0].name, 'outer');
done();
}, common.serverWait * 1.5);
Expand Down Expand Up @@ -133,7 +134,7 @@ describe('test-trace-http', function() {
};
writable.on('finish', function() {
endTransaction();
assert.equal(common.serverRes, result);
assert.equal(result, common.serverRes);
common.assertDurationCorrect(Date.now() - start);
done();
});
Expand Down Expand Up @@ -227,7 +228,7 @@ describe('test-trace-http', function() {
res.on('data', function(data) { result += data; });
res.on('end', function() {
endTransaction();
assert.equal(common.serverRes, result);
assert.equal(result, common.serverRes);
common.assertDurationCorrect(Date.now() - start);
done();
});
Expand All @@ -251,7 +252,7 @@ describe('test-trace-http', function() {
res.on('data', function(data) { result += data; });
res.on('end', function() {
endTransaction();
assert.equal(common.serverRes, result);
assert.equal(result, common.serverRes);
common.assertDurationCorrect(Date.now() - start);
server.close();
done();
Expand Down Expand Up @@ -354,7 +355,7 @@ describe('https', function() {
res.on('data', function(data) { result += data; });
res.on('end', function() {
endTransaction();
assert.equal(common.serverRes, result);
assert.equal(result, common.serverRes);
common.assertDurationCorrect(Date.now() - start);
secureServer.close();
done();
Expand Down

0 comments on commit 582ed50

Please sign in to comment.