优化结构
This commit is contained in:
@@ -63,3 +63,23 @@ func TestStoreReplaceSkipsUnchangedValues(t *testing.T) {
|
||||
t.Fatal("changed replace notification was not delivered")
|
||||
}
|
||||
}
|
||||
|
||||
func TestStoreSetSkipsUnchangedValues(t *testing.T) {
|
||||
var store Store
|
||||
updates := make(chan Config, 1)
|
||||
stop := store.Subscribe("mq", "rabbitmq", func(config Config) { updates <- config })
|
||||
defer stop()
|
||||
config := Config{Kind: "mq", Provider: "rabbitmq", Enabled: true, Values: json.RawMessage(`{"host":"localhost"}`)}
|
||||
store.Set(config)
|
||||
select {
|
||||
case <-updates:
|
||||
case <-time.After(time.Second):
|
||||
t.Fatal("initial set notification was not delivered")
|
||||
}
|
||||
store.Set(config)
|
||||
select {
|
||||
case update := <-updates:
|
||||
t.Fatalf("unchanged set emitted notification: %#v", update)
|
||||
case <-time.After(20 * time.Millisecond):
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user