package iot import ( "testing" "git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/consts" "git.5iot.com/iotlcm-public/iotlcm-admin-svr/internal/model" ) func TestNormalizeOrderItemProduct(t *testing.T) { tests := []struct { name string orderType int want string }{ {name: "renew", orderType: consts.OrderTypeCardRenew, want: "卡续费"}, {name: "change", orderType: consts.OrderTypeCardChange, want: "卡变更"}, {name: "subscribe", orderType: consts.OrderTypeCardSubscribe, want: "卡订购"}, } for _, test := range tests { t.Run(test.name, func(t *testing.T) { view := &model.TOrderItemViewModel{ ProductName: "余额充值", ProductSn: "BALANCE_RECHARGE", } normalizeOrderItemProduct(test.orderType, view) if view.ProductName != test.want || view.ProductSn != "" { t.Fatalf("got name=%q sn=%q, want name=%q and empty sn", view.ProductName, view.ProductSn, test.want) } }) } }