forked from newrelic/node-newrelic
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Updated index, issue-2155, and metric integration tests to nod…
…e:test
- Loading branch information
1 parent
ea8f743
commit b1f584d
Showing
6 changed files
with
96 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
'use strict' | ||
|
||
const test = require('node:test') | ||
const assert = require('node:assert') | ||
|
||
test('loading the application via index.js with no config', (t) => { | ||
process.env.NEW_RELIC_HOME = '/this/is/not/a/real/path' | ||
process.env.HOME = '/this/is/also/not/a/real/path' | ||
process.cwd = function () { | ||
return __dirname | ||
} | ||
|
||
/* eslint-disable no-console */ | ||
const logs = [] | ||
const logError = console.error | ||
t.after(() => { | ||
console.error = logError | ||
}) | ||
console.error = (...args) => logs.push(args) | ||
/* eslint-enable no-console */ | ||
|
||
let api | ||
assert.doesNotThrow(function () { | ||
api = require('../../../') | ||
}, 'should not die when the config file is not found') | ||
|
||
assert.ok(api, 'should have an API') | ||
assert.equal(api.agent, undefined, 'should not have an associated agent') | ||
assert.equal(logs.length, 2) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright 2020 New Relic Corporation. All rights reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
'use strict' | ||
|
||
const test = require('node:test') | ||
const tspl = require('@matteo.collina/tspl') | ||
|
||
const ruleTests = require('../../lib/cross_agent_tests/rules') | ||
const Config = require('../../../lib/config') | ||
const Normalizer = require('../../../lib/metrics/normalizer') | ||
|
||
test('cross agent tests', async (t) => { | ||
for (const ruleTest of ruleTests) { | ||
await t.test(ruleTest.testname, async (t) => { | ||
const plan = tspl(t, { plan: ruleTest.tests.length * 2 }) | ||
const config = new Config({}) | ||
|
||
const normalizer = new Normalizer(config, 'Url') | ||
normalizer.load(ruleTest.rules) | ||
|
||
ruleTest.tests.forEach(function (io) { | ||
const normalized = normalizer.normalize(io.input) | ||
|
||
if (io.expected === null) { | ||
plan.ok('ignored, not checking name') | ||
plan.ok(normalized.ignore, 'should ignore ' + io.input) | ||
} else { | ||
plan.equal( | ||
normalized.value, | ||
io.expected, | ||
'should normalize ' + io.input + ' to ' + io.expected | ||
) | ||
plan.equal(normalized.ignore, false, 'should not ignore ' + io.input) | ||
} | ||
}) | ||
}) | ||
} | ||
}) |