|
165 | 165 | end
|
166 | 166 |
|
167 | 167 | @testset "base_handler" begin
|
| 168 | + function structsequal(a::T, b::T)::Bool where T |
| 169 | + for name in propertynames(a) |
| 170 | + if getfield(a, name) != getfield(b, name) |
| 171 | + return false |
| 172 | + end |
| 173 | + end |
| 174 | + return true |
| 175 | + end |
| 176 | + |
168 | 177 | base_handler = function(request, state)
|
169 | 178 | @test request.target == "/test_path"
|
170 | 179 | @test state isa TestState
|
|
176 | 185 | test_handler = state_handler(base_handler, state)
|
177 | 186 | test_request = HTTP.Request("GET", "/test_path")
|
178 | 187 | res = Dash.HttpHelpers.handle(test_handler, test_request)
|
| 188 | + @test structsequal(res, test_handler(test_request)) #RequestHandlerFunction must be directly callable since HTTP.jl will use it |
179 | 189 | @test res.status == 200
|
180 | 190 | @test String(res.body) == "test1"
|
181 | 191 | @test startswith(HTTP.header(res, "Content-Type", ""), "text/plain")
|
|
192 | 202 | test_handler = state_handler(base_handler_http, state)
|
193 | 203 | test_request = HTTP.Request("GET", "/test_path2")
|
194 | 204 | res = Dash.HttpHelpers.handle(test_handler, test_request)
|
195 |
| - @test res.status == 200 |
| 205 | + @test structsequal(res, test_handler(test_request)) |
| 206 | + @test res.status == 200 |
196 | 207 | @test String(res.body) == "<html></html>"
|
197 | 208 | @test startswith(HTTP.header(res, "Content-Type", ""), "text/html")
|
198 | 209 | @test parse(Int, HTTP.header(res, "Content-Length", "0")) == sizeof("<html></html>")
|
|
207 | 218 | test_handler = state_handler(base_handler_js, state)
|
208 | 219 | test_request = HTTP.Request("GET", "/test_path3")
|
209 | 220 | res = Dash.HttpHelpers.handle(test_handler, test_request)
|
210 |
| - @test res.status == 200 |
| 221 | + @test structsequal(res, test_handler(test_request)) |
| 222 | + @test res.status == 200 |
211 | 223 | @test String(res.body) == "<html></html>"
|
212 | 224 | @test startswith(HTTP.header(res, "Content-Type", ""), "text/javascript")
|
213 | 225 | @test parse(Int, HTTP.header(res, "Content-Length", "0")) == sizeof("<html></html>")
|
|
0 commit comments