55 */
66
77const test = require ( 'tape' )
8- const { getConfig2 , clear2 , isContainerEnvironment } = require ( '../../lib/config' )
8+ const { getConfig , clear , isContainerEnvironment } = require ( '../../lib/config' )
99
1010function isRunGithubAction ( ) {
1111 return isContainerEnvironment
1212}
1313
1414
1515test ( 'should return the string value when the env value is string type' , function ( t ) {
16- clear2 ( )
16+ clear ( )
1717
1818 process . env [ 'PINPOINT_AGENT_ID' ] = "agentId"
1919 process . env [ 'PINPOINT_APPLICATION_NAME' ] = "appication name"
2020 process . env [ 'PINPOINT_COLLECTOR_IP' ] = "192.168.78.79"
2121 process . env [ 'PINPOINT_LOG_LEVEL' ] = "Debug"
2222
23- const given = getConfig2 ( )
23+ const given = getConfig ( )
2424 t . equal ( given . agentId , "agentId" , "given PINPOINT_AGENT_ID env, should equal config" )
2525 t . equal ( given . applicationName , "appication name" , "given PINPOINT_APPLICATION_NAME env, should equal config" )
2626 t . equal ( given . collectorIp , "192.168.78.79" , "given PINPOINT_COLLECTOR_IP env, should equal config" )
@@ -31,15 +31,15 @@ test('should return the string value when the env value is string type', functio
3131 delete process . env . PINPOINT_COLLECTOR_IP
3232 delete process . env . PINPOINT_LOG_LEVEL
3333
34- clear2 ( )
34+ clear ( )
3535 t . end ( )
3636} )
3737
3838const givenDefaultIdAndName = ( ) => {
3939 process . env [ 'PINPOINT_AGENT_ID' ] = "agentId"
4040 process . env [ 'PINPOINT_APPLICATION_NAME' ] = "appication name"
4141
42- const given = getConfig2 ( )
42+ const given = getConfig ( )
4343
4444 delete process . env . PINPOINT_AGENT_ID
4545 delete process . env . PINPOINT_APPLICATION_NAME
@@ -48,7 +48,7 @@ const givenDefaultIdAndName = () => {
4848}
4949
5050test ( 'should return the number value when the env value is number type' , function ( t ) {
51- clear2 ( )
51+ clear ( )
5252
5353 process . env [ 'PINPOINT_SERVICE_TYPE' ] = "1400"
5454 process . env [ 'PINPOINT_COLLECTOR_TCP_PORT' ] = "9894"
@@ -69,12 +69,12 @@ test('should return the number value when the env value is number type', functio
6969 delete process . env . PINPOINT_COLLECTOR_SPAN_PORT
7070 delete process . env . PINPOINT_SAMPLING_RATE
7171
72- clear2 ( )
72+ clear ( )
7373 t . end ( )
7474} )
7575
7676test ( 'should return the true value when the env value is boolean type' , function ( t ) {
77- clear2 ( )
77+ clear ( )
7878
7979 process . env [ 'PINPOINT_SAMPLING' ] = "true"
8080 process . env [ 'PINPOINT_ENABLE' ] = "true"
@@ -89,18 +89,18 @@ test('should return the true value when the env value is boolean type', function
8989 delete process . env . PINPOINT_ENABLE
9090 delete process . env . PINPOINT_CONTAINER
9191
92- clear2 ( )
92+ clear ( )
9393 t . end ( )
9494} )
9595
9696test ( 'should return the false value when the env value is boolean type' , function ( t ) {
97- clear2 ( )
97+ clear ( )
9898
9999 process . env [ 'PINPOINT_SAMPLING' ] = "false"
100100 process . env [ 'PINPOINT_ENABLE' ] = "false"
101101 process . env [ 'PINPOINT_CONTAINER' ] = "false"
102102
103- const given = getConfig2 ( )
103+ const given = getConfig ( )
104104 t . equal ( given . sampling , false , 'given PINPOINT_SAMPLING env, should equal config' )
105105 t . equal ( given . enable , false , 'given PINPOINT_ENABLE env, should equal config' )
106106 if ( ! isRunGithubAction ( ) ) {
@@ -111,12 +111,12 @@ test('should return the false value when the env value is boolean type', functio
111111 delete process . env . PINPOINT_ENABLE
112112 delete process . env . PINPOINT_CONTAINER
113113
114- clear2 ( )
114+ clear ( )
115115 t . end ( )
116116} )
117117
118118test ( 'should not exist in the process.env property when you do not set an environment variable' , function ( t ) {
119- clear2 ( )
119+ clear ( )
120120
121121 delete process . env . PINPOINT_COLLECTOR_IP
122122 delete process . env . PINPOINT_LOG_LEVEL
@@ -149,12 +149,12 @@ test('should not exist in the process.env property when you do not set an enviro
149149 t . equal ( given . collectorSpanPort , 9993 , 'No set PINPOINT_COLLECTOR_SPAN_PORT env, should equal default config' )
150150 t . equal ( given . sampleRate , 10 , 'No set PINPOINT_SAMPLING_RATE env, should equal default config' )
151151
152- clear2 ( )
152+ clear ( )
153153 t . end ( )
154154} )
155155
156156test ( `default config` , ( t ) => {
157- clear2 ( )
157+ clear ( )
158158
159159 const given = givenDefaultIdAndName ( )
160160 t . equal ( given . enabledActiveThreadCount , false , 'No set activeThreadCount' )
@@ -163,10 +163,10 @@ test(`default config`, (t) => {
163163} )
164164
165165test ( `detect container` , ( t ) => {
166- clear2 ( )
166+ clear ( )
167167
168168 process . env [ 'KUBERNETES_SERVICE_HOST' ] = "aaa"
169- const given = getConfig2 ( )
169+ const given = getConfig ( )
170170
171171 t . plan ( 1 )
172172 t . equal ( given . container , true , 'container detect' )
@@ -175,10 +175,10 @@ test(`detect container`, (t) => {
175175} )
176176
177177test ( `detect container2` , ( t ) => {
178- clear2 ( )
178+ clear ( )
179179
180180 if ( ! isRunGithubAction ( ) ) {
181- const given = getConfig2 ( )
181+ const given = getConfig ( )
182182 t . equal ( given . container , false , 'container detect' )
183183 }
184184
0 commit comments