42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package urgency
|
|
|
|
import "testing"
|
|
|
|
// zeroDeclarer 是一个未声明紧急度的生产者替身:它只实现契约本身。
|
|
type zeroDeclarer struct{}
|
|
|
|
func (zeroDeclarer) Urgency() Level { return LevelRoutine }
|
|
|
|
// TestLevel_ZeroValueIsRoutine 钉住本通道的默认保守:未声明(零值)与显式声明
|
|
// routine 同义,因此既有的、没标紧急度的事件生产者行为逐字不变。
|
|
func TestLevel_ZeroValueIsRoutine(t *testing.T) {
|
|
t.Parallel()
|
|
var l Level
|
|
if l != LevelRoutine {
|
|
t.Fatalf("zero Level = %v, want %v", l, LevelRoutine)
|
|
}
|
|
var d Declarer = zeroDeclarer{}
|
|
if got := d.Urgency(); got != LevelRoutine {
|
|
t.Fatalf("undeclared urgency = %v, want %v", got, LevelRoutine)
|
|
}
|
|
}
|
|
|
|
// TestLevel_String 钉住标签稳定(日志、审计与思考记录依赖它)。
|
|
func TestLevel_String(t *testing.T) {
|
|
t.Parallel()
|
|
cases := []struct {
|
|
in Level
|
|
want string
|
|
}{
|
|
{in: LevelRoutine, want: "routine"},
|
|
{in: LevelWarning, want: "warning"},
|
|
{in: LevelCritical, want: "critical"},
|
|
{in: Level(7), want: "urgency(7)"},
|
|
}
|
|
for _, tc := range cases {
|
|
if got := tc.in.String(); got != tc.want {
|
|
t.Fatalf("Level(%d).String() = %q, want %q", int(tc.in), got, tc.want)
|
|
}
|
|
}
|
|
}
|