优化结构

This commit is contained in:
Yvan
2026-08-22 23:02:44 +08:00
parent b18baf1547
commit 64459574b2
16 changed files with 158 additions and 73 deletions
@@ -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):
}
}