Skip to content

Commit

Permalink
Support for hapi 12 + 13
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt Loring committed Mar 19, 2016
1 parent 71e7355 commit 45fb0ca
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 6 deletions.
2 changes: 1 addition & 1 deletion lib/hooks/userspace/hook-hapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ var semver = require('semver');
var constants = require('../../constants.js');
var agent;

var SUPPORTED_VERSIONS = '8 - 11';
var SUPPORTED_VERSIONS = '8 - 13';

function connectionWrap(connection) {
return function connectionTrace() {
Expand Down
1 change: 1 addition & 0 deletions test/hooks/fixtures/hapi12/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('hapi');
8 changes: 8 additions & 0 deletions test/hooks/fixtures/hapi12/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "hapi12",
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"hapi": "^12.1.0"
}
}
1 change: 1 addition & 0 deletions test/hooks/fixtures/hapi13/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = require('hapi');
8 changes: 8 additions & 0 deletions test/hooks/fixtures/hapi13/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "hapi13",
"version": "1.0.0",
"main": "index.js",
"dependencies": {
"hapi": "^13.2.1"
}
}
18 changes: 13 additions & 5 deletions test/hooks/test-trace-hapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,25 @@ var common = require('./common.js');
var traceLabels = require('../../lib/trace-labels.js');
var http = require('http');
var assert = require('assert');
var semver = require('semver');

var server;

var versions = {
hapi8: require('./fixtures/hapi8'),
hapi9: require('./fixtures/hapi9'),
hapi10: require('./fixtures/hapi10'),
hapi11: require('./fixtures/hapi11')
hapi8: './fixtures/hapi8',
hapi9: './fixtures/hapi9',
hapi10: './fixtures/hapi10',
hapi11: './fixtures/hapi11',
hapi12: './fixtures/hapi12',
hapi13: './fixtures/hapi13'
};

Object.keys(versions).forEach(function(version) {
var hapi = versions[version];
if (version.substring(4) > 10 && semver.satisfies(process.version, '<4')) {
// v11 started using ES6 features (const)
return;
}
var hapi = require(versions[version]);
describe(version, function() {
afterEach(function(done) {
common.cleanTraces();
Expand Down Expand Up @@ -124,6 +131,7 @@ Object.keys(versions).forEach(function(version) {

it('should accurately measure get time, after + get', function(done) {
if (version.substring(4) > 10) {
// after was removed in v11 https://github.com/hapijs/hapi/issues/2850
return done();
}
var afterSuccess = false;
Expand Down

0 comments on commit 45fb0ca

Please sign in to comment.