function() return math.random() > 0.5 and "plain" or "imageboard" end local pages = { index = { route = "/", name = "home", methods = { GET={} } }, paste = { route = "/_paste", name = "post_story", methods = { GET={}, POST={ title = rng_any, text = rng_any, pasteas = rng_subdomain, markup = rng_markup tags = rng_any; } } }, edit = { route = "/_edit", name = "edit", methods = { GET={ story=rng_storyid }, POST={ title = rng_any, text = rng_any, pasteas = rng_subdomain, markup = rng_markup, tags = rng_any }, } }, --TODO:bio login = { route = "/_login", name = "login", methods = { GET={}, POST={ user = rng_subdomain, pass = rng_any }, } }, claim = { route = "/_claim", name = "claim", methods = { GET = {}, POST = { user = rng_subdomain } } }, download = { route = "/_download", name = "download", methods = { GET = { story = rng_storyid }, } }, preview = { route = "/_preview", name = "preview", methods = { POST = {}, } }, search = { route = "/_search", name = "search", methods = { GET = {}, } } } local request_stub_m = {} function http_response(req,errcode,str) req.responded = true req.errcode = errcode req.message = str end function http_request_get_host(reqstub) return "localhost:8888" end function http_request_populate_post(reqstub) reqstub.post_populated = true end local function fuzz_endpoint(endpoint, parameters) for i = 1,100 do local req = {} for paramtype, params in pairs(parameters) do end end return true end describe("smr",function() for name, obj in pairs(pages) do describe("endpoint " .. name,function() for method,parameters in pairs(obj.methods) do describe("method " .. method,function() local fname = string.format("%s_%s",name,string.lower(method)) it("should be named appropriately",function() local f = assert(io.open("endpoints/"..fname .. ".lua","r")) end) it("should run without errors",function() require("endpoints." .. fname) end) it("should return a function",function() function configure(...) print("configure called") end local pagefunc = assert(require("endpoints." .. fname)) assert(type(pagefunc) == "function") end) it("should call http_response() at some point",function() local pagefunc = require("endpoints." .. fname) assert(fuzz_endpoint(pagefunc,parameters)) end) end) end end) end end)