Files
WoW-Hybrid-gateway/tests/native_item_batch_probe_test.lua
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

33 lines
2.9 KiB
Lua

local timers={};local requests={};local cache={}
issecretvalue=function(v)return v=='SECRET'end
C_Timer={After=function(_,fn)timers[#timers+1]=fn end}
GWReadOnlyItemBatchData={profile='fixture',items={{id=10,name='Expected',class=4,subclass=1,quality=2},{id=11,name='Expected too',class=7,subclass=0,quality=1}}}
C_Item={RequestLoadItemDataByID=function(id)requests[#requests+1]=id;cache[id]=true end,
GetItemInfo=function(id)if cache[id]then return id==10 and'Expected'or'Wrong',nil,id==10 and 2 or 1 end end,
GetItemInfoInstant=function(id)return id,nil,nil,nil,nil,id==10 and 4 or 7,id==10 and 1 or 0 end}
local get=C_Item.GetItemInfo
dofile(assert(arg[1]));assert(#requests==0 and #timers==0)
assert(not GWStartReadOnlyItemBatchProbe('SECRET'));assert(GWStartReadOnlyItemBatchProbe('abc123'));assert(not GWStartReadOnlyItemBatchProbe('abc124'))
while #timers>0 do local fn=table.remove(timers,1);fn()end
local r=GatewayDiagnosticsSaved.itemBatchProbe;assert(r.complete and r.checked==2 and r.passed==1 and r.errors==0 and #r.mismatches==1 and r.mismatches[1].id==11)
assert(C_Item.GetItemInfo==get and #requests==2)
print('Explicit start only, no login work, original item API, metadata mismatch reporting and complete bounded read-only batches pass.')
GWReadOnlyItemBatchData.items={}
for id=1000,1200 do table.insert(GWReadOnlyItemBatchData.items,{id=id,name='Item'..id,class=12,subclass=0,quality=1})end
local outstanding=0;local maximum=0;local queued={}
C_Item.RequestLoadItemDataByID=function(id)queued[id]=true;outstanding=outstanding+1;maximum=math.max(maximum,outstanding);assert(outstanding<=96)end
C_Item.GetItemInfo=function(id)if queued[id]then queued[id]=nil;outstanding=outstanding-1 end;return'Item'..id,nil,1 end
C_Item.GetItemInfoInstant=function(id)return id,nil,nil,nil,nil,12,0 end
assert(GWStartReadOnlyItemBatchProbe('beef'))
while #timers>0 do local fn=table.remove(timers,1);fn()end
r=GatewayDiagnosticsSaved.itemBatchProbe;assert(r.complete and r.passed==201 and r.checked==201 and r.errors==0 and maximum==96 and outstanding==0)
print('A full 201-record batch crosses request windows without exceeding96outstanding native requests.')
GWReadOnlyItemBatchData.items={{id=20,name='Native icon',class=4,subclass=1,quality=2,icon=8534400},{id=21,name='Wrong icon',class=4,subclass=1,quality=2,icon=8534401}}
C_Item.RequestLoadItemDataByID=function()end
C_Item.GetItemInfo=function(id)return id==20 and'Native icon'or'Wrong icon',nil,2 end
C_Item.GetItemInfoInstant=function(id)return id,nil,nil,nil,8534400,4,1 end
assert(GWStartReadOnlyItemBatchProbe('cafe'))
while #timers>0 do local fn=table.remove(timers,1);fn()end
r=GatewayDiagnosticsSaved.itemBatchProbe;assert(r.complete and r.checked==2 and r.passed==1 and r.errors==0 and #r.mismatches==1 and r.mismatches[1].id==21 and r.mismatches[1].icon==8534400)
print('Optional native icon references are checked independently of matching item names and classes.')