feat: 卡实名时间以上游 archiveTime 为准并记录实名时间历史,新增二次实名批次
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
Some checks failed
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Has been cancelled
This commit is contained in:
42
internal/gateway/upstream_time_test.go
Normal file
42
internal/gateway/upstream_time_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
"time"
|
||||
)
|
||||
|
||||
func TestRealnameStatusRespUpstreamRealnameAt(t *testing.T) {
|
||||
cases := []struct {
|
||||
name string
|
||||
body string
|
||||
want string
|
||||
}{
|
||||
{"移动返回实名时间", `{"archiveTime":"2026-07-16 19:43:39","iccid":"89860885192590574640","realStatus":true}`, "2026-07-16T19:43:39+08:00"},
|
||||
{"电信不返回", `{"iccid":"8986112520903884400","realStatus":true}`, ""},
|
||||
{"联通 extend 无时间", `{"extend":"已实名","iccid":"89860625750010460562","realStatus":true}`, ""},
|
||||
{"未实名 null", `{"archiveTime":null,"iccid":"898608851925D1284902","realStatus":false}`, ""},
|
||||
{"未实名但带时间忽略", `{"archiveTime":"2026-07-16 19:43:39","realStatus":false}`, ""},
|
||||
{"空串", `{"archiveTime":"","realStatus":true}`, ""},
|
||||
{"格式错误", `{"archiveTime":"07/16/2026","realStatus":true}`, ""},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
var resp RealnameStatusResp
|
||||
if err := json.Unmarshal([]byte(tc.body), &resp); err != nil {
|
||||
t.Fatalf("unmarshal: %v", err)
|
||||
}
|
||||
got := resp.UpstreamRealnameAt()
|
||||
if tc.want == "" {
|
||||
if got != nil {
|
||||
t.Fatalf("want nil, got %v", got)
|
||||
}
|
||||
return
|
||||
}
|
||||
want, _ := time.Parse(time.RFC3339, tc.want)
|
||||
if got == nil || !got.Equal(want) {
|
||||
t.Fatalf("want %v, got %v", want, got)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user