22
33const assert = require ( 'node:assert/strict' )
44const { assertObjectContains } = require ( '../../../integration-tests/helpers' )
5+ const { getConfigFresh } = require ( './helpers/config' )
56const { describe, it, beforeEach, afterEach } = require ( 'tap' ) . mocha
67
78require ( './setup/core' )
@@ -78,11 +79,11 @@ describe('process-tags', () => {
7879 } )
7980
8081 it ( 'should set sensible values' , ( ) => {
81- const basedirTag = processTags . tags . find ( ( [ name ] ) => name === 'entrypoint.basedir' )
82- const nameTag = processTags . tags . find ( ( [ name ] ) => name === 'entrypoint.name' )
83- const typeTag = processTags . tags . find ( ( [ name ] ) => name === 'entrypoint.type' )
84- const workdirTag = processTags . tags . find ( ( [ name ] ) => name === 'entrypoint.workdir' )
85- const packageNameTag = processTags . tags . find ( ( [ name ] ) => name === 'package.json.name' )
82+ const basedirTag = processTags . tags [ 0 ]
83+ const nameTag = processTags . tags [ 1 ]
84+ const typeTag = processTags . tags [ 2 ]
85+ const workdirTag = processTags . tags [ 3 ]
86+ const packageNameTag = processTags . tags [ 4 ]
8687
8788 // Entrypoint values should be set (may vary depending on test runner)
8889 assert . ok ( basedirTag )
@@ -102,11 +103,13 @@ describe('process-tags', () => {
102103 } )
103104
104105 it ( 'should sort tags alphabetically' , ( ) => {
105- assert . strictEqual ( processTags . tags [ 0 ] [ 0 ] , 'entrypoint.basedir' )
106- assert . strictEqual ( processTags . tags [ 1 ] [ 0 ] , 'entrypoint.name' )
107- assert . strictEqual ( processTags . tags [ 2 ] [ 0 ] , 'entrypoint.type' )
108- assert . strictEqual ( processTags . tags [ 3 ] [ 0 ] , 'entrypoint.workdir' )
109- assert . strictEqual ( processTags . tags [ 4 ] [ 0 ] , 'package.json.name' )
106+ assertObjectContains ( processTags . tags , [
107+ [ 'entrypoint.basedir' ] ,
108+ [ 'entrypoint.name' ] ,
109+ [ 'entrypoint.type' ] ,
110+ [ 'entrypoint.workdir' ] ,
111+ [ 'package.json.name' ]
112+ ] )
110113 } )
111114
112115 it ( 'should serialize tags correctly' , ( ) => {
@@ -309,7 +312,6 @@ describe('process-tags', () => {
309312
310313 describe ( 'DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED' , ( ) => {
311314 let env
312- let getConfig
313315 let SpanProcessor
314316
315317 beforeEach ( ( ) => {
@@ -319,7 +321,6 @@ describe('process-tags', () => {
319321
320322 afterEach ( ( ) => {
321323 process . env = env
322- delete require . cache [ require . resolve ( '../src/config' ) ]
323324 delete require . cache [ require . resolve ( '../src/span_processor' ) ]
324325 delete require . cache [ require . resolve ( '../src/process-tags' ) ]
325326 } )
@@ -328,11 +329,9 @@ describe('process-tags', () => {
328329 process . env . DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED = 'true'
329330
330331 // Need to reload config first, then process-tags (which reads from config)
331- delete require . cache [ require . resolve ( '../src/config' ) ]
332332 delete require . cache [ require . resolve ( '../src/process-tags' ) ]
333333
334- getConfig = require ( '../src/config' )
335- const config = getConfig ( )
334+ const config = getConfigFresh ( )
336335
337336 assert . ok ( config . propagateProcessTags )
338337 assert . strictEqual ( config . propagateProcessTags . enabled , true )
@@ -347,8 +346,7 @@ describe('process-tags', () => {
347346 it ( 'should disable process tags propagation when set to false' , ( ) => {
348347 process . env . DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED = 'false'
349348
350- getConfig = require ( '../src/config' )
351- const config = getConfig ( )
349+ const config = getConfigFresh ( )
352350
353351 assert . ok ( config . propagateProcessTags )
354352 assert . strictEqual ( config . propagateProcessTags . enabled , false )
@@ -362,8 +360,7 @@ describe('process-tags', () => {
362360 it ( 'should disable process tags propagation when not set' , ( ) => {
363361 // Don't set the environment variable
364362
365- getConfig = require ( '../src/config' )
366- const config = getConfig ( )
363+ const config = getConfigFresh ( )
367364
368365 assert . notStrictEqual ( config . propagateProcessTags ?. enabled , true )
369366
0 commit comments