相关问题优化以及新功能开发
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m57s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m57s
迁移 155- 157
This commit is contained in:
63
internal/task/polling_cardstatus_handler_test.go
Normal file
63
internal/task/polling_cardstatus_handler_test.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package task
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/pkg/constants"
|
||||
)
|
||||
|
||||
// TestShouldStopPolling 验证风险状态独立卡的轮询停止判断逻辑
|
||||
func TestShouldStopPolling(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
isStandalone bool
|
||||
gatewayExtend string
|
||||
want bool
|
||||
}{
|
||||
{
|
||||
name: "独立卡+风险停机 -> 停止轮询",
|
||||
isStandalone: true,
|
||||
gatewayExtend: constants.GatewayCardExtendRiskStop,
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "独立卡+已销户 -> 停止轮询",
|
||||
isStandalone: true,
|
||||
gatewayExtend: constants.GatewayCardExtendCancelled,
|
||||
want: true,
|
||||
},
|
||||
{
|
||||
name: "非独立卡+风险停机 -> 不停止轮询",
|
||||
isStandalone: false,
|
||||
gatewayExtend: constants.GatewayCardExtendRiskStop,
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "独立卡+机卡分离停机 -> 不停止轮询",
|
||||
isStandalone: true,
|
||||
gatewayExtend: constants.GatewayCardExtendMachineSeparated,
|
||||
want: false,
|
||||
},
|
||||
{
|
||||
name: "独立卡+空扩展 -> 不停止轮询",
|
||||
isStandalone: true,
|
||||
gatewayExtend: "",
|
||||
want: false,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
card := &model.IotCard{
|
||||
IsStandalone: tc.isStandalone,
|
||||
GatewayExtend: tc.gatewayExtend,
|
||||
}
|
||||
got := shouldStopPollingForRisk(card, tc.gatewayExtend)
|
||||
if got != tc.want {
|
||||
t.Errorf("shouldStopPollingForRisk(standalone=%v, extend=%q) = %v, 期望 %v",
|
||||
tc.isStandalone, tc.gatewayExtend, got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user