Add nudge_channels to MessagingConfig schema (gt-3shmx)
- Add NudgeChannels field to MessagingConfig struct in types.go - Initialize NudgeChannels map in NewMessagingConfig() - Add validation in validateMessagingConfig(): channel names must be non-empty and each channel must have at least one recipient - Add tests for valid nudge channels and empty recipient validation 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
committed by
Steve Yegge
parent
d28ba6e2c6
commit
d94fb4669b
@@ -566,6 +566,8 @@ func TestMessagingConfigRoundTrip(t *testing.T) {
|
||||
Readers: []string{"@town"},
|
||||
RetainCount: 100,
|
||||
}
|
||||
original.NudgeChannels["workers"] = []string{"gastown/polecats/*", "gastown/crew/*"}
|
||||
original.NudgeChannels["witnesses"] = []string{"*/witness"}
|
||||
|
||||
if err := SaveMessagingConfig(path, original); err != nil {
|
||||
t.Fatalf("SaveMessagingConfig: %v", err)
|
||||
@@ -606,6 +608,17 @@ func TestMessagingConfigRoundTrip(t *testing.T) {
|
||||
if a, ok := loaded.Announces["alerts"]; !ok || a.RetainCount != 100 {
|
||||
t.Error("announce not preserved")
|
||||
}
|
||||
|
||||
// Check nudge channels
|
||||
if len(loaded.NudgeChannels) != 2 {
|
||||
t.Errorf("NudgeChannels count = %d, want 2", len(loaded.NudgeChannels))
|
||||
}
|
||||
if workers, ok := loaded.NudgeChannels["workers"]; !ok || len(workers) != 2 {
|
||||
t.Error("workers nudge channel not preserved")
|
||||
}
|
||||
if witnesses, ok := loaded.NudgeChannels["witnesses"]; !ok || len(witnesses) != 1 {
|
||||
t.Error("witnesses nudge channel not preserved")
|
||||
}
|
||||
}
|
||||
|
||||
func TestMessagingConfigValidation(t *testing.T) {
|
||||
@@ -696,6 +709,27 @@ func TestMessagingConfigValidation(t *testing.T) {
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
{
|
||||
name: "valid config with nudge channels",
|
||||
config: &MessagingConfig{
|
||||
Type: "messaging",
|
||||
Version: 1,
|
||||
NudgeChannels: map[string][]string{
|
||||
"workers": {"gastown/polecats/*", "gastown/crew/*"},
|
||||
},
|
||||
},
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "nudge channel with no recipients",
|
||||
config: &MessagingConfig{
|
||||
Version: 1,
|
||||
NudgeChannels: map[string][]string{
|
||||
"empty": {},
|
||||
},
|
||||
},
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
Reference in New Issue
Block a user