-- test_item_augment.lua
-- Verifies HDG.StaticData.ItemAugment accessor.

dofile("wow_mock.lua")
dofile("../data/HDGR_VendorAugment.lua")
dofile("../data/HDGR_ItemAugment.lua")
dofile("../Core/HDGR_Constants.lua")
dofile("../Core/HDGR_Format.lua")
dofile("../Modules/HDGR_StaticData.lua")

HDG.StaticData:OnInitialize()

local function assertEq(actual, expected, msg)
    if actual ~= expected then
        error(string.format("FAIL [%s]: expected %s got %s", msg or "?",
            tostring(expected), tostring(actual)))
    end
end

-- Pick a known itemID from generated file
local sampleID, sampleEntry = next(HDGR_ItemAugment)
assert(sampleID, "ItemAugment should not be empty")

-- :Get(itemID) returns the entry
local got = HDG.StaticData.ItemAugment:Get(sampleID)
assert(got, ":Get returns non-nil for known item")
-- Verify at least one of the augmentable fields is present. `sources` is the
-- unified curated-source list (type=N entries) consumed by _bakeSourceTags /
-- _bakeItemAugmentBackfill; it sits alongside the rep-gate fields.
local hasAny = got.factionID or got.minRep or got.factionName
                or got.sourceType or got.altSourceType or got.sources
assert(hasAny, ":Get returns entry with at least one augmentable field")

-- :Get(unknown) returns nil
assertEq(HDG.StaticData.ItemAugment:Get(99999999), nil, ":Get(unknown) is nil")

print("test_item_augment: PASS")
