Skip to content

Commit

Permalink
chore(test): Replaced t.equals with t.equal in versioned tests
Browse files Browse the repository at this point in the history
Signed-off-by: mrickard <maurice@mauricerickard.com>
  • Loading branch information
mrickard committed Jun 30, 2023
1 parent 7e06d10 commit e02ed91
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 52 deletions.
42 changes: 21 additions & 21 deletions test/versioned/hapi/errors.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ tap.test('Hapi error handling', function (t) {
})

runTest(t, function (errors, statusCode) {
t.equals(errors.length, 0, 'should have no errors')
t.equals(statusCode, 200, 'should have a 200 status code')
t.equal(errors.length, 0, 'should have no errors')
t.equal(statusCode, 200, 'should have a 200 status code')
t.end()
})
})
Expand All @@ -54,11 +54,11 @@ tap.test('Hapi error handling', function (t) {
})

runTest(t, function (errors, statusCode) {
t.equals(errors.length, 1, 'should have one error')
t.equal(errors.length, 1, 'should have one error')

t.equals(errors[0][2], 'rejected promise error', 'should have expected error message')
t.equal(errors[0][2], 'rejected promise error', 'should have expected error message')

t.equals(statusCode, 500, 'should have expected error code')
t.equal(statusCode, 500, 'should have expected error code')
t.end()
})
})
Expand All @@ -73,9 +73,9 @@ tap.test('Hapi error handling', function (t) {
})

runTest(t, function (errors, statusCode) {
t.equals(errors.length, 1, 'should have one error')
t.equals(errors[0][2], 'thrown error', 'should have expected error message')
t.equals(statusCode, 500, 'should have expected error code')
t.equal(errors.length, 1, 'should have one error')
t.equal(errors[0][2], 'thrown error', 'should have expected error message')
t.equal(statusCode, 500, 'should have expected error code')
t.end()
})
})
Expand All @@ -94,9 +94,9 @@ tap.test('Hapi error handling', function (t) {
})

runTest(t, function (errors, statusCode) {
t.equals(errors.length, 1, 'should have one error')
t.equals(errors[0][2], 'middleware error', 'should have expected error message')
t.equals(statusCode, 500, 'should have expected error code')
t.equal(errors.length, 1, 'should have one error')
t.equal(errors[0][2], 'middleware error', 'should have expected error message')
t.equal(statusCode, 500, 'should have expected error code')
t.end()
})
})
Expand All @@ -117,9 +117,9 @@ tap.test('Hapi error handling', function (t) {
})

runTest(t, (errors, statusCode) => {
t.equals(errors.length, 1, 'has 1 reported error')
t.equals(errors[0][2], 'route handler error', 'has correct error message')
t.equals(statusCode, 400, 'has expected 400 status code')
t.equal(errors.length, 1, 'has 1 reported error')
t.equal(errors[0][2], 'route handler error', 'has correct error message')
t.equal(statusCode, 400, 'has expected 400 status code')
t.end()
})
})
Expand All @@ -140,9 +140,9 @@ tap.test('Hapi error handling', function (t) {
})

runTest(t, (errors, statusCode) => {
t.equals(errors.length, 1, 'has 1 reported error')
t.equals(errors[0][2], 'route handler error', 'has correct error message')
t.equals(statusCode, 400, 'has expected 400 status code')
t.equal(errors.length, 1, 'has 1 reported error')
t.equal(errors[0][2], 'route handler error', 'has correct error message')
t.equal(statusCode, 400, 'has expected 400 status code')
t.end()
})
})
Expand All @@ -162,9 +162,9 @@ tap.test('Hapi error handling', function (t) {
})

runTest(t, (errors, statusCode) => {
t.equals(errors.length, 1, 'has 1 reported error')
t.equals(errors[0][2], 'route handler error', 'has correct error message')
t.equals(statusCode, 500, 'has expected 500 status code')
t.equal(errors.length, 1, 'has 1 reported error')
t.equal(errors[0][2], 'route handler error', 'has correct error message')
t.equal(statusCode, 500, 'has expected 500 status code')
t.end()
})
})
Expand All @@ -184,7 +184,7 @@ tap.test('Hapi error handling', function (t) {
})

runTest(t, (errors, statusCode) => {
t.equals(errors.length, 0, 'has no reported errors')
t.equal(errors.length, 0, 'has no reported errors')
t.ok([200, 204].includes(statusCode), 'has expected 200 or 204 status code')
t.end()
})
Expand Down
8 changes: 4 additions & 4 deletions test/versioned/ioredis/ioredis-3.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,16 @@ tap.test('ioredis instrumentation', function (t) {

agent.on('transactionFinished', function (tx) {
const root = tx.trace.root
t.equals(root.children.length, 2, 'root has two children')
t.equal(root.children.length, 2, 'root has two children')

const setSegment = root.children[0]
t.equals(setSegment.name, 'Datastore/operation/Redis/set')
t.equal(setSegment.name, 'Datastore/operation/Redis/set')

// ioredis operations return promise, any 'then' callbacks will be sibling segments
// of the original redis call
const getSegment = root.children[1]
t.equals(getSegment.name, 'Datastore/operation/Redis/get')
t.equals(getSegment.children.length, 0, 'should not contain any segments')
t.equal(getSegment.name, 'Datastore/operation/Redis/get')
t.equal(getSegment.children.length, 0, 'should not contain any segments')

t.end()
})
Expand Down
8 changes: 4 additions & 4 deletions test/versioned/ioredis/ioredis.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,16 +71,16 @@ tap.test('ioredis instrumentation', (t) => {

agent.on('transactionFinished', function (tx) {
const root = tx.trace.root
t.equals(root.children.length, 2, 'root has two children')
t.equal(root.children.length, 2, 'root has two children')

const setSegment = root.children[0]
t.equals(setSegment.name, 'Datastore/operation/Redis/set')
t.equal(setSegment.name, 'Datastore/operation/Redis/set')

// ioredis operations return promise, any 'then' callbacks will be sibling segments
// of the original redis call
const getSegment = root.children[1]
t.equals(getSegment.name, 'Datastore/operation/Redis/get')
t.equals(getSegment.children.length, 0, 'should not contain any segments')
t.equal(getSegment.name, 'Datastore/operation/Redis/get')
t.equal(getSegment.children.length, 0, 'should not contain any segments')

t.end()
})
Expand Down
46 changes: 23 additions & 23 deletions test/versioned/redis/redis.tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,27 @@ test('Redis instrumentation', { timeout: 20000 }, function (t) {
}

t.ok(agent.getTransaction(), 'transaction should still still be visible')
t.equals(value, 'arglbargle', 'memcached client should still work')
t.equal(value, 'arglbargle', 'memcached client should still work')

const trace = transaction.trace
t.ok(trace, 'trace should exist')
t.ok(trace.root, 'root element should exist')
t.equals(trace.root.children.length, 1, 'there should be only one child of the root')
t.equal(trace.root.children.length, 1, 'there should be only one child of the root')

const setSegment = trace.root.children[0]
const setAttributes = setSegment.getAttributes()
t.ok(setSegment, 'trace segment for set should exist')
t.equals(setSegment.name, 'Datastore/operation/Redis/set', 'should register the set')
t.equals(setAttributes.key, '"testkey"', 'should have the set key as a attribute')
t.equals(setSegment.children.length, 1, 'set should have an only child')
t.equal(setSegment.name, 'Datastore/operation/Redis/set', 'should register the set')
t.equal(setAttributes.key, '"testkey"', 'should have the set key as a attribute')
t.equal(setSegment.children.length, 1, 'set should have an only child')

const getSegment = setSegment.children[0].children[0]
const getAttributes = getSegment.getAttributes()
t.ok(getSegment, 'trace segment for get should exist')

t.equals(getSegment.name, 'Datastore/operation/Redis/get', 'should register the get')
t.equal(getSegment.name, 'Datastore/operation/Redis/get', 'should register the get')

t.equals(getAttributes.key, '"testkey"', 'should have the get key as a attribute')
t.equal(getAttributes.key, '"testkey"', 'should have the get key as a attribute')

t.ok(getSegment.children.length >= 1, 'get should have a callback segment')

Expand Down Expand Up @@ -194,7 +194,7 @@ test('Redis instrumentation', { timeout: 20000 }, function (t) {
t.error(error)

const segment = agent.tracer.getSegment().parent
t.equals(segment.getAttributes().key, '"saveme"', 'should have `key` attribute')
t.equal(segment.getAttributes().key, '"saveme"', 'should have `key` attribute')
t.end()
})
})
Expand Down Expand Up @@ -232,14 +232,14 @@ test('Redis instrumentation', { timeout: 20000 }, function (t) {
const trace = transaction.trace
const setSegment = trace.root.children[0]
const attributes = setSegment.getAttributes()
t.equals(attributes.host, METRIC_HOST_NAME, 'should have host as attribute')
t.equals(
t.equal(attributes.host, METRIC_HOST_NAME, 'should have host as attribute')
t.equal(
attributes.port_path_or_id,
String(params.redis_port),
'should have port as attribute'
)
t.equals(attributes.database_name, String(DB_INDEX), 'should have database id as attribute')
t.equals(attributes.product, 'Redis', 'should have product attribute')
t.equal(attributes.database_name, String(DB_INDEX), 'should have database id as attribute')
t.equal(attributes.product, 'Redis', 'should have product attribute')
})
})
})
Expand All @@ -260,13 +260,13 @@ test('Redis instrumentation', { timeout: 20000 }, function (t) {

const setSegment = transaction.trace.root.children[0]
const attributes = setSegment.getAttributes()
t.equals(attributes.host, undefined, 'should not have host attribute')
t.equals(attributes.port_path_or_id, undefined, 'should not have port attribute')
t.equals(attributes.database_name, undefined, 'should not have db name attribute')
t.equal(attributes.host, undefined, 'should not have host attribute')
t.equal(attributes.port_path_or_id, undefined, 'should not have port attribute')
t.equal(attributes.database_name, undefined, 'should not have db name attribute')

transaction.end()
const unscoped = transaction.metrics.unscoped
t.equals(
t.equal(
unscoped['Datastore/instance/Redis/' + HOST_ID],
undefined,
'should not have instance metric'
Expand Down Expand Up @@ -304,20 +304,20 @@ test('Redis instrumentation', { timeout: 20000 }, function (t) {
const selectSegment = setSegment1.children[0].children[0]
const setSegment2 = selectSegment.children[0].children[0]

t.equals(setSegment1.name, 'Datastore/operation/Redis/set', 'should register the first set')
t.equals(
t.equal(setSegment1.name, 'Datastore/operation/Redis/set', 'should register the first set')
t.equal(
setSegment1.getAttributes().database_name,
String(DB_INDEX),
'should have the starting database id as attribute for the first set'
)
t.equals(selectSegment.name, 'Datastore/operation/Redis/select', 'should register the select')
t.equals(
t.equal(selectSegment.name, 'Datastore/operation/Redis/select', 'should register the select')
t.equal(
selectSegment.getAttributes().database_name,
String(DB_INDEX),
'should have the starting database id as attribute for the select'
)
t.equals(setSegment2.name, 'Datastore/operation/Redis/set', 'should register the second set')
t.equals(
t.equal(setSegment2.name, 'Datastore/operation/Redis/set', 'should register the second set')
t.equal(
setSegment2.getAttributes().database_name,
String(SELECTED_DB),
'should have the selected database id as attribute for the second set'
Expand All @@ -330,7 +330,7 @@ function checkMetrics(t, metrics, expected) {
Object.keys(expected).forEach(function (name) {
t.ok(metrics[name], 'should have metric ' + name)
if (metrics[name]) {
t.equals(
t.equal(
metrics[name].callCount,
expected[name],
'should have ' + expected[name] + ' calls for ' + name
Expand Down

0 comments on commit e02ed91

Please sign in to comment.