MCPcopy Create free account
hub / github.com/apache/dubbo-go / TestRootConfigProcessCopyOnWrite

Function TestRootConfigProcessCopyOnWrite

config/root_config_test.go:122–142  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

120}
121
122func TestRootConfigProcessCopyOnWrite(t *testing.T) {
123 base := NewRootConfigBuilder().Build()
124 base.Registries["demoZK"] = &RegistryConfig{
125 Protocol: "zookeeper",
126 Timeout: "10s",
127 Address: "127.0.0.1:2181",
128 }
129 base.Consumer.RequestTimeout = "3s"
130 SetRootConfig(*base)
131
132 oldSnapshot := GetRootConfig()
133 eventValue := "dubbo:\n registries:\n demoZK:\n protocol: zookeeper\n timeout: 11s\n address: 127.0.0.1:2181\n consumer:\n request-timeout: 6s\n"
134 oldSnapshot.Process(&config_center.ConfigChangeEvent{Key: "test", Value: eventValue})
135
136 newSnapshot := GetRootConfig()
137 assert.NotSame(t, oldSnapshot, newSnapshot)
138 assert.Equal(t, "10s", oldSnapshot.Registries["demoZK"].Timeout)
139 assert.Equal(t, "3s", oldSnapshot.Consumer.RequestTimeout)
140 assert.Equal(t, "11s", newSnapshot.Registries["demoZK"].Timeout)
141 assert.Equal(t, "6s", newSnapshot.Consumer.RequestTimeout)
142}

Callers

nothing calls this directly

Calls 6

NewRootConfigBuilderFunction · 0.85
SetRootConfigFunction · 0.85
GetRootConfigFunction · 0.85
ProcessMethod · 0.65
BuildMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected