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

chore: Migrate bunyan, pino, and winston tests to node:test #2634

Merged
merged 6 commits into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 19 additions & 12 deletions test/lib/logging-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@
*/

'use strict'
const helpers = module.exports
const tap = require('tap')

tap.Test.prototype.addAssert('validateAnnotations', 2, validateLogLine)
const assert = require('node:assert')

// NOTE: pino adds hostname to log lines which is why we don't check it here
helpers.CONTEXT_KEYS = [
const CONTEXT_KEYS = [
'entity.name',
'entity.type',
'entity.guid',
Expand All @@ -23,21 +21,30 @@ helpers.CONTEXT_KEYS = [
* To be registered as a tap assertion
*/
function validateLogLine({ line: logLine, message, level, config }) {
this.equal(
assert.equal(
logLine['entity.name'],
config.applications()[0],
'should have entity name that matches app'
)
this.equal(logLine['entity.guid'], 'test-guid', 'should have set entitye guid')
this.equal(logLine['entity.type'], 'SERVICE', 'should have entity type of SERVICE')
this.equal(logLine.hostname, config.getHostnameSafe(), 'should have proper hostname')
this.match(logLine.timestamp, /[0-9]{10}/, 'should have proper unix timestamp')
this.notOk(logLine.message.includes('NR-LINKING'), 'should not contain NR-LINKING metadata')
assert.equal(logLine['entity.guid'], 'test-guid', 'should have set entity guid')
assert.equal(logLine['entity.type'], 'SERVICE', 'should have entity type of SERVICE')
assert.equal(logLine.hostname, config.getHostnameSafe(), 'should have proper hostname')
assert.equal(/[0-9]{10}/.test(logLine.timestamp), true, 'should have proper unix timestamp')
assert.equal(
logLine.message.includes('NR-LINKING'),
false,
'should not contain NR-LINKING metadata'
)
if (message) {
this.equal(logLine.message, message, 'message should be the same as log')
assert.equal(logLine.message, message, 'message should be the same as log')
}

if (level) {
this.equal(logLine.level, level, 'level should be string value not number')
assert.equal(logLine.level, level, 'level should be string value not number')
}
}

module.exports = {
CONTEXT_KEYS,
validateLogLine
}
271 changes: 0 additions & 271 deletions test/versioned/bunyan/bunyan.tap.js

This file was deleted.

Loading
Loading