107 lines
1.8 KiB
Lua
107 lines
1.8 KiB
Lua
|
|
||
|
local pages = {
|
||
|
index = {
|
||
|
route = "/",
|
||
|
name = "home",
|
||
|
methods = {
|
||
|
GET={}
|
||
|
}
|
||
|
},
|
||
|
paste = {
|
||
|
route = "/_paste",
|
||
|
name = "post_story",
|
||
|
methods = {
|
||
|
GET={},
|
||
|
POST={}
|
||
|
}
|
||
|
},
|
||
|
edit = {
|
||
|
route = "/_edit",
|
||
|
name = "edit",
|
||
|
methods = {
|
||
|
GET={},
|
||
|
POST={},
|
||
|
}
|
||
|
},
|
||
|
--TODO:bio
|
||
|
login = {
|
||
|
route = "/_login",
|
||
|
name = "login",
|
||
|
methods = {
|
||
|
GET={},
|
||
|
POST={},
|
||
|
}
|
||
|
},
|
||
|
claim = {
|
||
|
route = "/_claim",
|
||
|
name = "claim",
|
||
|
methods = {
|
||
|
GET = {},
|
||
|
POST = {}
|
||
|
}
|
||
|
},
|
||
|
download = {
|
||
|
route = "/_download",
|
||
|
name = "download",
|
||
|
methods = {
|
||
|
GET = {},
|
||
|
}
|
||
|
},
|
||
|
preview = {
|
||
|
route = "/_preview",
|
||
|
name = "preview",
|
||
|
methods = {
|
||
|
POST = {},
|
||
|
}
|
||
|
},
|
||
|
search = {
|
||
|
route = "/_search",
|
||
|
name = "search",
|
||
|
methods = {
|
||
|
GET = {},
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
local request_stub_m = {
|
||
|
}
|
||
|
function http_response(req,errcode,str)
|
||
|
s = true
|
||
|
end
|
||
|
function http_request_get_host(reqstub)
|
||
|
return "localhost:8888"
|
||
|
end
|
||
|
function http_request_populate_post(reqstub)
|
||
|
reqstub.post_populated = 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(fname .. ".lua","r"))
|
||
|
end)
|
||
|
it("should run without errors",function()
|
||
|
require(fname)
|
||
|
end)
|
||
|
it("should return a function",function()
|
||
|
local pagefunc = assert(require(fname))
|
||
|
assert(type(pagefunc) == "function")
|
||
|
end)
|
||
|
it("calls http_response()",function()
|
||
|
local pagefunc = require(fname)
|
||
|
local s = false
|
||
|
local reqstub = {}
|
||
|
pagefunc(reqstub)
|
||
|
end)
|
||
|
|
||
|
end)
|
||
|
end
|
||
|
end)
|
||
|
end
|
||
|
end)
|