Bind league tables strengths and live profiles to engine reads (by Codex)

This commit is contained in:
Codex committed 2026-10-28 21:53:18 +01:00
1 parent f9e8719b2d
commit 1c35698dbe
24 files changed
+463 -20

No files matched your search

+17
View File
@@ -355,6 +355,23 @@ int main() {
rejects([&]{engine_almanac_key({{"kind","calendar"},{"year",2026.5}});});
rejects([&]{engine_almanac_key({{"kind","day"},{"date","2026-02-30"}});});
rejects([&]{engine_almanac_key({{"kind","match"},{"id",""}});});
auto report_bundle=fixture();
const auto report_wrap=[&](const char*,const Json &data){return Json{{"messageType","snapshot"},{"meta",report_bundle.at("desktop").at("meta")},{"data",data}};};
const Json report_index_data={{"kind","report-index"},{"leagues",{{{"id","league:live"},{"name","Live League"},{"nationId","nation:test"},{"members",{"club:6","club:7"}},{"clubCount",2},{"matchdays",2},{"played",1},{"own",true}}}}};
const auto report_index_read=report_wrap("report-index",report_index_data);
Json report_rows=Json::array(),strength_rows=Json::array();
for(int n=0;n<2;++n){const auto id=n?"club:7":"club:6";Json team={{"id",id},{"name",n?"Live B":"Live A"}};
report_rows.push_back({{"team",team},{"original",n},{"rank",n+1},{"played",1},{"wins",n?0:1},{"draw",0},{"loss",n?1:0},{"gf",n?0:2},{"ga",n?2:0},{"diff",n?-2:2},{"points",n?0:3},{"form",n?0:3},{"form_text",n?"N":"S"}});
strength_rows.push_back({{"team",team},{"original",n},{"basis","squad"},{"keeper",nullptr},{"defence",71},{"midfield",72},{"attack",73},{"strength",72}});
}
const Json report_data={{"kind","league-report"},{"leagueId","league:live"},{"filter",0},{"table",report_rows},{"strengths",strength_rows},{"zones",nullptr}};
const auto report_read=report_wrap("league-report",report_data);const auto report_value=engine_report_projection(report_bundle,report_index_read,report_read,"league:live",0);
require(report_value.at("table")[0].at("name")=="Live A"&&report_value.at("strengths")[0].at("keeper").is_null(),"live report name/unknown position was fabricated");
auto bad_report=report_read;bad_report["meta"]["careerId"]="other";rejects([&]{engine_report_projection(report_bundle,report_index_read,bad_report,"league:live",0);});
bad_report=report_read;bad_report["data"]["table"][0]["team"]["id"]="club:other";rejects([&]{engine_report_projection(report_bundle,report_index_read,bad_report,"league:live",0);});
bad_report=report_read;bad_report["data"]["table"][1]["rank"]=1;rejects([&]{engine_report_projection(report_bundle,report_index_read,bad_report,"league:live",0);});
bad_report=report_read;bad_report["data"]["filter"]=3;rejects([&]{engine_report_projection(report_bundle,report_index_read,bad_report,"league:live",0);});
auto bad_index=report_index_read;bad_index["data"]["leagues"][0]["members"][1]="club:6";rejects([&]{engine_report_index(report_bundle,bad_index);});
std::cout << "engine DTO, exact money, scope and booking tests passed\n";
return 0;
} catch (const std::exception &e) { std::cerr << e.what() << '\n'; return 1; }