小程序一些功能更新
This commit is contained in:
38
internal/logic/admin_level_s10_test.go
Normal file
38
internal/logic/admin_level_s10_test.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package logic
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/gogf/gf/v2/os/gtime"
|
||||
)
|
||||
|
||||
// ============================================================================
|
||||
// 约定 S10 单测(纯函数,不依赖 DB)
|
||||
//
|
||||
// level_expire_at IS NULL/零值 = 永久有效;续费 / 手动开通**不得把永久覆写成有限期**。
|
||||
// ============================================================================
|
||||
|
||||
func TestLevelExpireTransitionErr(t *testing.T) {
|
||||
future := gtime.New("2999-01-01 00:00:00")
|
||||
|
||||
cases := []struct {
|
||||
name string
|
||||
prevPermanent bool
|
||||
newExpire *gtime.Time
|
||||
wantErr bool
|
||||
}{
|
||||
{"永久 → 永久(NULL) 放行", true, nil, false},
|
||||
{"永久 → 有限期 拒绝(S10)", true, future, true},
|
||||
{"有限期 → 有限期 放行", false, future, false},
|
||||
{"有限期 → 永久(NULL) 放行", false, nil, false},
|
||||
}
|
||||
for _, c := range cases {
|
||||
err := levelExpireTransitionErr(c.prevPermanent, c.newExpire)
|
||||
if c.wantErr && err == nil {
|
||||
t.Errorf("%s: 期望报错,实得 nil", c.name)
|
||||
}
|
||||
if !c.wantErr && err != nil {
|
||||
t.Errorf("%s: 期望放行,实得 err=%v", c.name, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user