Testing the platform · 47 / 69
Read a mocked cache
YOUR TASK
Make this happen
The exported contract describes ctx.cache.get as an (ok, value) call. A strict mock supplies both results. No real cache or network request is involved.
Read the cases in
lesson.test.lua, then choose Check solution to see what needs to change.Update
subject.luauntil every test passes. Keep the supplied tests unchanged.
Read the starter and tests
subject.lua
exports.cached = function(key: string) return nil end
lesson.test.lua
local t = require("test")
local subject = require("cococo.subject")
t.it("reads supplied value", function()
local s = subject.load()
t.mock.host("ctx.cache.get"):returns(true, "ready")
t.expect(s.cached("job")):eq("ready")
end)