package hostorg import "testing" // TestNormalizeListQueryAllowsCoinSellerComputedSorts 锁定币商余额和累充 USDT 排序字段会被后台列表查询接受。 func TestNormalizeListQueryAllowsCoinSellerComputedSorts(t *testing.T) { for _, sortBy := range []string{sortByMerchantBalance, sortByTotalRechargeUSDT} { query := normalizeListQuery(listQuery{Page: 1, PageSize: 50, SortBy: sortBy, SortDirection: "asc"}) if query.SortBy != sortBy || query.SortDirection != "asc" { t.Fatalf("expected sort %s asc to be kept, got sort_by=%q direction=%q", sortBy, query.SortBy, query.SortDirection) } } } // TestBDRoleFromStatusPathUsesLeaderTableWithAPIPrefix 锁定线上真实 FullPath 带 /api/v1 前缀时,BD Leader 状态仍然写独立负责人表。 func TestBDRoleFromStatusPathUsesLeaderTableWithAPIPrefix(t *testing.T) { role, target := bdRoleFromStatusPath("/api/v1/admin/bd-leaders/:user_id/status") if role != "bd_leader" || target != "bd_leader_profiles" { t.Fatalf("leader status route must use bd_leader_profiles, got role=%q target=%q", role, target) } role, target = bdRoleFromStatusPath("/api/v1/admin/bds/:user_id/status") if role != "bd" || target != "bd_profiles" { t.Fatalf("bd status route must use bd_profiles, got role=%q target=%q", role, target) } } // TestSortCoinSellerListItemsComputedFields 验证 wallet 聚合字段排序只改变展示顺序,不改动币商身份数据。 func TestSortCoinSellerListItemsComputedFields(t *testing.T) { items := []*CoinSellerListItem{ {UserID: 1, MerchantBalance: 100, TotalRechargeUSDTMicro: 30_000_000}, {UserID: 2, MerchantBalance: 300, TotalRechargeUSDTMicro: 10_000_000}, {UserID: 3, MerchantBalance: 200, TotalRechargeUSDTMicro: 20_000_000}, } sortCoinSellerListItems(items, sortByMerchantBalance, "desc") if got := []int64{items[0].UserID, items[1].UserID, items[2].UserID}; got[0] != 2 || got[1] != 3 || got[2] != 1 { t.Fatalf("merchant balance desc order mismatch: %v", got) } sortCoinSellerListItems(items, sortByTotalRechargeUSDT, "asc") if got := []int64{items[0].UserID, items[1].UserID, items[2].UserID}; got[0] != 2 || got[1] != 3 || got[2] != 1 { t.Fatalf("total recharge usdt asc order mismatch: %v", got) } }