refactor(*): 稳定期治理 - 收敛核心架构、错误语义并修复跨项目数据竞态
This commit is contained in:
1 parent
bacd502f5c
commit
b5f3413ded
298 files changed
+12681
-26428
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestPaginationJSONUsesPageSizeCamelCase(t *testing.T) {
|
||||
payloads := []any{
|
||||
SkillList{TotalCount: 3, HasMore: true, NextOffset: 20, Page: 1, PageSize: 20},
|
||||
AdminUserPage{Total: 1, Page: 1, Limit: 20},
|
||||
WalletSummary{Total: 1, Page: 1, Limit: 30},
|
||||
APICallLogPage{Total: 1, Page: 1, Limit: 50},
|
||||
}
|
||||
for _, payload := range payloads {
|
||||
body, err := json.Marshal(payload)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
var object map[string]json.RawMessage
|
||||
if err := json.Unmarshal(body, &object); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
for _, key := range []string{"page_size", "total_count", "has_more", "next_offset", "limit"} {
|
||||
if _, found := object[key]; found {
|
||||
t.Fatalf("%T still encodes %s: %s", payload, key, body)
|
||||
}
|
||||
}
|
||||
if _, found := object["pageSize"]; !found {
|
||||
t.Fatalf("%T missing pageSize: %s", payload, body)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user