Browse Source
后台有上架商品时列表与订单发货都读 app_goods,没有上架商品时仍退回业务库 goods。 Co-authored-by: Cursor <cursoragent@cursor.com>along
4 changed files with 91 additions and 22 deletions
@ -0,0 +1,32 @@ |
|||||
|
package pay |
||||
|
|
||||
|
import ( |
||||
|
"testing" |
||||
|
|
||||
|
"yunyan/comm" |
||||
|
"yunyan/pb" |
||||
|
) |
||||
|
|
||||
|
func TestListedGoodsPrefersEnabledAdminGoods(t *testing.T) { |
||||
|
got := listedGoods([]*comm.AppGoods{ |
||||
|
{GoodsId: "old", Enable: false, Name: "下架"}, |
||||
|
{GoodsId: "vip_month_1", Enable: true, Name: "月度", Price: 990, Usagetype: int32(pb.UsageType_VIP), Viptime: 30}, |
||||
|
}, []*pb.DBGoods{ |
||||
|
{Id: "legacy", Enable: true, Name: "旧商品"}, |
||||
|
}) |
||||
|
if len(got) != 1 || got[0].Id != "vip_month_1" || got[0].Viptime != 30 { |
||||
|
t.Fatalf("应只下发后台已上架商品,实际 %#v", got) |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
func TestListedGoodsFallsBackWhenAdminHasNothingOnShelf(t *testing.T) { |
||||
|
got := listedGoods([]*comm.AppGoods{ |
||||
|
{GoodsId: "draft", Enable: false}, |
||||
|
}, []*pb.DBGoods{ |
||||
|
{Id: "legacy", Enable: true}, |
||||
|
{Id: "off", Enable: false}, |
||||
|
}) |
||||
|
if len(got) != 1 || got[0].Id != "legacy" { |
||||
|
t.Fatalf("后台没有上架商品时应退回业务库已上架商品,实际 %#v", got) |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue