You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
929 B
32 lines
929 B
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)
|
|
}
|
|
}
|
|
|