material_manage_system/internal/service/inbound_test.go
2026-09-20 10:31:28 +08:00

29 lines
731 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package service
import "testing"
// resolveWarningEnabled 决定入库时写预警规则要不要启用。老客户端只会传 warning_stock、
// 从不传 warning_enabled,那种情况下必须保持原来的"带上阈值即启用"行为。
func TestResolveWarningEnabled(t *testing.T) {
enabled := true
disabled := false
cases := []struct {
name string
in *bool
want bool
}{
{"未传则默认启用", nil, true},
{"显式启用", &enabled, true},
{"显式关闭", &disabled, false},
}
for _, tc := range cases {
t.Run(tc.name, func(t *testing.T) {
if got := resolveWarningEnabled(tc.in); got != tc.want {
t.Fatalf("resolveWarningEnabled(%v) = %v, want %v", tc.in, got, tc.want)
}
})
}
}