(t *testing.T)
| 120 | } |
| 121 | |
| 122 | func 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 | } |
nothing calls this directly
no test coverage detected