Skip to content

Commit 9519131

Browse files
committed
[#404] Configuration Reconstructing
1 parent 00b0fd6 commit 9519131

File tree

1 file changed

+7
-19
lines changed

1 file changed

+7
-19
lines changed

test/config.test.js

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
const test = require('tape')
88
const { clear, getConfig, readConfigJson, readRootConfigFile, getMainModulePath } = require('../lib/config')
99
const { HttpStatusCodeErrorsBuilder, getHttpStatusCodeErrors, clearHttpStatusCodeErrors } = require('../lib/instrumentation/http/http-status-code-errors-builder')
10-
const log = require('../lib/utils/log/logger')
1110
const { ConfigBuilder } = require('../lib/config-builder')
11+
const path = require('path')
1212

1313
test('Agent ID required field', function (t) {
1414
t.plan(1)
@@ -61,28 +61,17 @@ test('deadline config', (t) => {
6161
t.equal(conf.collector.deadlineMinutes, 10)
6262
})
6363

64-
test('main module path', (t) => {
65-
clear()
66-
const conf = readRootConfigFile()
67-
t.deepEqual(conf, {}, 'configuration is null object')
68-
let actual = getMainModulePath(require)
69-
70-
actual = getMainModulePath({})
71-
t.true(actual === undefined, 'getMainModulePath({}) return value is undefined')
72-
73-
actual = getMainModulePath()
74-
t.true(actual === undefined, 'getMainModulePath() return value is undefined')
64+
test('ConfigBuilder pathForRequireFunction Learning Test', (t) => {
65+
let actual = {}.main
66+
t.true(actual === undefined, '{}.main return value is undefined')
7567

76-
actual = getMainModulePath(null)
77-
t.true(actual === undefined, 'getMainModulePath(null) return value is undefined')
78-
79-
actual = getMainModulePath({ main: {} })
68+
actual = { main: {} }.main.filename
8069
t.true(actual === undefined, 'getMainModulePath({ main: {} }) return value is undefined')
8170

82-
actual = getMainModulePath({ main: { filename: '/test' } })
71+
actual = path.dirname({ main: { filename: '/test' } }.main.filename)
8372
t.equal(actual, '/', 'getMainModulePath({ main: { filename: \' / test\' } }) return value is /')
8473

85-
actual = getMainModulePath({ main: { filename: '/test/test1' } })
74+
actual = path.dirname({ main: { filename: '/test/test1' } }.main.filename)
8675
t.equal(actual, '/test', 'getMainModulePath({ main: { filename: \' / test\' } }) return value is /')
8776

8877
t.end()
@@ -97,7 +86,6 @@ test('main module path', (t) => {
9786
// public static final int AGENT_ID_MAX_LEN = 24;
9887
// }
9988
test('Agent ID length check', (t) => {
100-
clear()
10189
process.env['PINPOINT_AGENT_ID'] = 'agentId'
10290
process.env['PINPOINT_APPLICATION_NAME'] = 'appication-name'
10391
process.env['PINPOINT_AGENT_NAME'] = 'agent-name'

0 commit comments

Comments
 (0)