修复套餐快照集成测试与自动购包幂等
This commit is contained in:
@@ -1,8 +1,5 @@
|
||||
package order
|
||||
|
||||
// testIDMask 用于将纳秒时间戳截断为合法的 uint 主键范围,仅限测试用。
|
||||
const testIDMask = testIDMask
|
||||
|
||||
import (
|
||||
"context"
|
||||
"strconv"
|
||||
@@ -17,6 +14,9 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
// testIDMask 用于将纳秒时间戳截断为合法的 uint 主键范围,仅限测试用。
|
||||
const testIDMask = 0x7fffffff
|
||||
|
||||
// TestSynchronousPurchasePersistsImmutableTermsSnapshots 验证同步主套餐和加油包固化购买时计时条款。
|
||||
func TestSynchronousPurchasePersistsImmutableTermsSnapshots(t *testing.T) {
|
||||
tx := testutil.NewPostgresTransaction(t)
|
||||
@@ -99,13 +99,13 @@ func TestCEndPurchasePersistsSnapshotAndActivatesImmediately(t *testing.T) {
|
||||
service := &Service{shopPackageAllocationStore: postgres.NewShopPackageAllocationStore(tx), logger: zap.NewNop()}
|
||||
now := time.Now()
|
||||
order := &model.Order{
|
||||
Model: gorm.Model{ID: uint(time.Now().UnixNano() & testIDMask)},
|
||||
OrderNo: "UR55-CEND-" + strconv.FormatInt(time.Now().UnixNano(), 10),
|
||||
OrderType: model.OrderTypeSingleCard,
|
||||
BuyerType: model.BuyerTypePersonal,
|
||||
IotCardID: &card.ID,
|
||||
Model: gorm.Model{ID: uint(time.Now().UnixNano() & testIDMask)},
|
||||
OrderNo: "UR55-CEND-" + strconv.FormatInt(time.Now().UnixNano(), 10),
|
||||
OrderType: model.OrderTypeSingleCard,
|
||||
BuyerType: model.BuyerTypePersonal,
|
||||
IotCardID: &card.ID,
|
||||
TotalAmount: 100,
|
||||
Generation: 1,
|
||||
Generation: 1,
|
||||
}
|
||||
if err := service.activateMainPackage(context.Background(), tx, order, pkg, constants.AssetWalletResourceTypeIotCard, card.ID, now); err != nil {
|
||||
t.Fatalf("C 端购买创建主套餐失败:%v", err)
|
||||
|
||||
Reference in New Issue
Block a user