fix: 修复顺运宝分页总数误判 (#60)

This commit is contained in:
chengma
2026-08-09 19:01:04 +08:00
parent 3bd9c9a2c3
commit 919522ff79
5 changed files with 56 additions and 20 deletions
+2 -1
View File
@@ -327,7 +327,7 @@ func TestClient_ListTotal和ListPage(t *testing.T) {
t.Fatalf("list 失败: %v", err)
}
if pageTotal != 1 {
t.Fatalf("list 响应内 total 应该是 1,实际 %d", pageTotal)
t.Fatalf("list 响应内当前页条数应该是 1,实际 %d", pageTotal)
}
if len(rows) != 1 || rows[0].ID != 75104587 || rows[0].Code != "260728TB95MJTQ" {
t.Fatalf("列表结果不对: %+v", rows)
@@ -342,6 +342,7 @@ func TestClient_ListPage要求合法Total(t *testing.T) {
{"缺少total", map[string]any{"list": []any{}}},
{"total类型错误", map[string]any{"list": []any{}, "total": "1"}},
{"total为负数", map[string]any{"list": []any{}, "total": -1}},
{"total与list长度不一致", map[string]any{"list": []any{map[string]any{"id": 1}}, "total": 0}},
} {
t.Run(test.name, func(t *testing.T) {
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {