ScuttleBot

scuttlebot / internal / topology / topology_test.go
Blame History Raw 36 lines
1
package topology_test
2
3
import (
4
"testing"
5
6
"github.com/conflicthq/scuttlebot/internal/topology"
7
)
8
9
func TestValidateName(t *testing.T) {
10
cases := []struct {
11
name string
12
channel string
13
wantErr bool
14
}{
15
{"valid fleet", "#fleet", false},
16
{"valid project", "#project.myapp", false},
17
{"valid subtopic", "#project.myapp.tasks.backend", false},
18
{"valid task", "#task.01HX123", false},
19
{"missing prefix", "fleet", true},
20
{"empty after prefix", "#", true},
21
{"contains space", "#my channel", true},
22
}
23
24
for _, tc := range cases {
25
t.Run(tc.name, func(t *testing.T) {
26
err := topology.ValidateName(tc.channel)
27
if tc.wantErr && err == nil {
28
t.Errorf("ValidateName(%q): expected error, got nil", tc.channel)
29
}
30
if !tc.wantErr && err != nil {
31
t.Errorf("ValidateName(%q): unexpected error: %v", tc.channel, err)
32
}
33
})
34
}
35
}
36

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button