@@ -368,7 +368,6 @@ func TestGetConfigAndInitValNotNil(t *testing.T) {
368
368
Configurations : map [string ]interface {}{"testKey" : "testUpdatedValue" },
369
369
}
370
370
})
371
- defer patch .Reset ()
372
371
373
372
client := createMockApolloConfig (120 )
374
373
cf := client .GetConfig ("testNotFound" )
@@ -380,6 +379,26 @@ func TestGetConfigAndInitValNotNil(t *testing.T) {
380
379
// cache should be updated with new configuration
381
380
Assert (t , client .cache .GetConfig ("testNotFound" ), NotNilVal ())
382
381
Assert (t , client .cache .GetConfig ("testNotFound" ).GetValue ("testKey" ), Equal ("testUpdatedValue" ))
382
+ Assert (t , client .appConfig .NamespaceName , Equal ("application,testNotFound" ))
383
+ patch .Reset ()
384
+
385
+ // second replace
386
+ patch1 := gomonkey .ApplyMethod (reflect .TypeOf (apc ), "SyncWithNamespace" , func (_ * remote.AbsApolloConfig , namespace string , appConfigFunc func () config.AppConfig ) * config.ApolloConfig {
387
+ return & config.ApolloConfig {
388
+ ApolloConnConfig : config.ApolloConnConfig {
389
+ AppID : "testID" ,
390
+ NamespaceName : "testNotFound1" ,
391
+ },
392
+ Configurations : map [string ]interface {}{"testKey" : "testUpdatedValue" },
393
+ }
394
+ })
395
+ defer patch1 .Reset ()
396
+ client .appConfig .NamespaceName = "testNotFound1"
397
+ cf1 := client .GetConfig ("testNotFound1" )
398
+ Assert (t , cf1 , NotNilVal ())
399
+ Assert (t , client .cache .GetConfig ("testNotFound1" ), NotNilVal ())
400
+ // appConfig namespace existed, should not be appended
401
+ Assert (t , client .appConfig .NamespaceName , Equal ("testNotFound1" ))
383
402
}
384
403
385
404
func TestGetConfigAndInitValNil (t * testing.T ) {
0 commit comments