mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-09-26 13:33:27 -04:00
a9ce423bdc
CLOSES #1275, CLOSES #1295, CLOSES #1384, CLOSES #1628, CLOSES #1677, CLOSES #1682, CLOSES #1691, CLOSES #1813, CLOSES #1822, CLOSES #1861, CLOSES #1867, CLOSES #1868, CLOSES #1869, CLOSES #1870, CLOSES #1871, CLOSES #1872, CLOSES #1874, CLOSES #1876, CLOSES #1878, CLOSES #1880, CLOSES #1881, CLOSES #1882, CLOSES #1884, CLOSES #1885, CLOSES #1886, CLOSES #1887, CLOSES #1888, CLOSES #1889, CLOSES #1890, CLOSES #1891, CLOSES #1892, CLOSES #1893, CLOSES #1894, CLOSES #1895, CLOSES #1896, CLOSES #1899, CLOSES #1900, CLOSES #1901
98 lines
3.3 KiB
Lua
98 lines
3.3 KiB
Lua
package.path = "./?.lua;./?/init.lua;" .. package.path
|
|
if not _G.love then _G.love = require("tests.love_stub") end
|
|
|
|
local T = require("tests.harness")
|
|
local check, eq = T.check, T.eq
|
|
|
|
local ModUpdate = require("src.mods.ModUpdate")
|
|
local LauncherMods = require("src.mods.LauncherMods")
|
|
local RomImporter = require("src.import.RomImporter")
|
|
|
|
local RELEASES = {
|
|
{ version = "1.1.10", zip = { url = "https://example.invalid/a.zip" } },
|
|
{ version = "1.0.0", zip = { url = "https://example.invalid/b.zip" } },
|
|
}
|
|
|
|
local oldPump = ModUpdate.pumpDownloadZip
|
|
local oldInstall = LauncherMods.installDownloadedZip
|
|
local oldDeps = LauncherMods.checkDependencies
|
|
local installedAs
|
|
|
|
ModUpdate.pumpDownloadZip = function() return true, "install.zip" end
|
|
LauncherMods.installDownloadedZip = function() return true, installedAs end
|
|
LauncherMods.checkDependencies = function() return { hasIssues = false } end
|
|
|
|
local function launcher(installed, wanted)
|
|
installedAs = wanted
|
|
local ri = setmetatable({
|
|
mods = { { id = "gym", name = "Gym Challenge", version = installed,
|
|
github = "someone/gym" } },
|
|
modUpdateInfo = {
|
|
gym = { status = "available", latest = "1.1.10", best = RELEASES[1],
|
|
releases = RELEASES, checkedAt = 1 },
|
|
},
|
|
_modInstall = {
|
|
h = {}, version = wanted,
|
|
spec = { modId = "gym", name = "Gym Challenge", verb = "Updated",
|
|
notice = "mod" },
|
|
},
|
|
}, RomImporter)
|
|
ri._refreshMods = function(self) self.mods[1].version = wanted end
|
|
return ri
|
|
end
|
|
|
|
do
|
|
local ri = launcher("1.0.0", "1.1.10")
|
|
ri:_pumpModInstall()
|
|
eq(ri:_modUpdateInfo("gym").status, "current",
|
|
"the mod that just installed the latest release is up to date")
|
|
eq(ri:_modUpdateInfo("gym").latest, "1.1.10",
|
|
"and the release list it was judged against is still on the row")
|
|
check(ri.modNotice and ri.modNotice.ok, "the install still reports success")
|
|
check(ri.modNotice.text:find("1.1.10", 1, true) ~= nil,
|
|
"with the version it landed")
|
|
eq(ri._modInstall, nil, "and the job is done")
|
|
end
|
|
|
|
do
|
|
local ri = launcher("0.9.0", "1.0.0")
|
|
ri:_pumpModInstall()
|
|
eq(ri:_modUpdateInfo("gym").status, "available",
|
|
"an older release is still behind the newest one")
|
|
eq(ri:_modUpdateInfo("gym").latest, "1.1.10",
|
|
"which is the release the badge names")
|
|
end
|
|
|
|
do
|
|
local ri = launcher("1.0.0", "1.1.10")
|
|
local pending = { mod = ri.mods[1], h = {} }
|
|
ri._modInfoFetch = { pending }
|
|
ri:_pumpModInstall()
|
|
eq(pending.mod.version, "1.1.10",
|
|
"the in-flight check judges against the version now on disk")
|
|
|
|
local oldFetch = ModUpdate.pumpFetchReleases
|
|
local oldCache = ModUpdate.readCache
|
|
ModUpdate.pumpFetchReleases = function() return true, RELEASES end
|
|
ModUpdate.readCache = function() return nil end
|
|
ri:_pumpModInfoFetch()
|
|
ModUpdate.pumpFetchReleases = oldFetch
|
|
ModUpdate.readCache = oldCache
|
|
eq(ri:_modUpdateInfo("gym").status, "current",
|
|
"so it lands on the same answer instead of bringing the chip back")
|
|
end
|
|
|
|
do
|
|
local ri = launcher("1.0.0", "1.1.10")
|
|
ri.modUpdateInfo = {}
|
|
ri:_pumpModInstall()
|
|
eq(ri:_modUpdateInfo("gym"), nil,
|
|
"no release list means no verdict to invent")
|
|
end
|
|
|
|
ModUpdate.pumpDownloadZip = oldPump
|
|
LauncherMods.installDownloadedZip = oldInstall
|
|
LauncherMods.checkDependencies = oldDeps
|
|
|
|
T.finish("mod update badge")
|