Aetherance commented on code in PR #3252:
URL: https://github.com/apache/dubbo-go/pull/3252#discussion_r2958078769
##########
cluster/router/tag/router_test.go:
##########
@@ -399,3 +399,60 @@ tags:
assert.Nil(t, value)
})
}
+
+func TestSetStaticConfig(t *testing.T) {
+ t.Run("empty tag config is ignored", func(t *testing.T) {
+ p, err := NewTagPriorityRouter()
+ require.NoError(t, err)
+
+ p.SetStaticConfig(&global.RouterConfig{Key: "test-app"})
+
+ value, ok := p.routerConfigs.Load("test-app" +
constant.TagRouterRuleSuffix)
+ assert.False(t, ok)
+ assert.Nil(t, value)
+ })
+
+ t.Run("static tag config is cloned and stored with default enabled",
func(t *testing.T) { // NOSONAR
+ p, err := NewTagPriorityRouter()
+ require.NoError(t, err)
+
+ cfg := &global.RouterConfig{
+ Key: "test-app",
+ Tags: []global.Tag{{
+ Name: "gray",
+ Addresses: []string{"192.168.0.1:20000"}, //
NOSONAR
+ }},
+ }
+
+ p.SetStaticConfig(cfg)
+ cfg.Tags[0].Addresses[0] = "192.168.0.9:20000" // NOSONAR
+
+ value, ok := p.routerConfigs.Load("test-app" +
constant.TagRouterRuleSuffix)
+ require.True(t, ok)
+ routerCfg := value.(global.RouterConfig)
+ assert.True(t, *routerCfg.Enabled)
+ assert.True(t, *routerCfg.Valid)
+ assert.Equal(t, "192.168.0.1:20000",
routerCfg.Tags[0].Addresses[0]) // NOSONAR
+ })
Review Comment:
fixed by #3251
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]