feat: 重构顺运宝规格主链路 (#88)

This commit is contained in:
chengma
2026-08-10 12:24:23 +08:00
parent 5bb1258462
commit d1165b9e17
28 changed files with 985 additions and 531 deletions
+35
View File
@@ -0,0 +1,35 @@
package spec
import (
"strings"
"testing"
)
func TestSpecKey_只折叠空白(t *testing.T) {
got, err := SpecKey(" 黑色,\tM【建議40-50公斤】 \n")
if err != nil {
t.Fatal(err)
}
if got != "黑色, M【建議40-50公斤】" {
t.Fatalf("SpecKey=%q", got)
}
}
func TestSpecKey_不依赖规格解析(t *testing.T) {
got, err := SpecKey("紅色,3XL建議80-90公斤】")
if err != nil {
t.Fatal(err)
}
if got != "紅色,3XL建議80-90公斤】" {
t.Fatalf("SpecKey=%q", got)
}
}
func TestSpecKey_拒绝空值和超长值(t *testing.T) {
if _, err := SpecKey(" \t\n "); err == nil {
t.Fatal("空规格必须报错")
}
if _, err := SpecKey(strings.Repeat("规", MaxKeyRunes+1)); err == nil {
t.Fatal("超长规格必须报错")
}
}