File size: 1,322 Bytes
6a7089a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | package report
import (
"testing"
)
func TestSecurityLevelColor(t *testing.T) {
tests := []struct {
level string
want string
}{
{level: "LOCKED", want: string(colorSuccess)},
{level: "GUARDED", want: string(colorWarning)},
{level: "ELEVATED", want: string(colorWarning)},
{level: "EXPOSED", want: string(colorDanger)},
{level: "UNKNOWN", want: string(colorDanger)},
}
for _, tt := range tests {
if got := SecurityLevelColor(tt.level); got != tt.want {
t.Fatalf("SecurityLevelColor(%q) = %q, want %q", tt.level, got, tt.want)
}
}
}
func TestDefaultListenStatus(t *testing.T) {
tests := []struct {
mode string
explicit string
want string
}{
{mode: "menu", want: "stopped"},
{mode: "server", want: "starting"},
{mode: "bridge", want: "starting"},
{mode: "mcp", want: "starting"},
{mode: "server", explicit: "running", want: "running"},
{mode: "other", want: ""},
}
for _, tt := range tests {
if got := defaultListenStatus(tt.mode, tt.explicit); got != tt.want {
t.Fatalf("defaultListenStatus(%q, %q) = %q, want %q", tt.mode, tt.explicit, got, tt.want)
}
}
}
func TestFormatListenValuePlain(t *testing.T) {
got := formatListenValue("127.0.0.1:9867", "")
if got != "127.0.0.1:9867" {
t.Fatalf("formatListenValue() = %q, want plain address", got)
}
}
|