Skip to content

Commit 753afd4

Browse files
committed
Add test for app dependencies
1 parent a5c168b commit 753afd4

2 files changed

Lines changed: 37 additions & 0 deletions

File tree

test/app/deps.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export ->(req) {
2+
req.respond(@env[:foo][:foo] + @env[:bar][:bar])
3+
}

test/test_app.rb

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,3 +290,37 @@ def test_route_method
290290
assert_equal File.join(APP_ROOT, 'about/foo.md'), route[:target][:fn]
291291
end
292292
end
293+
294+
class AppDependenciesTest < Minitest::Test
295+
Status = Qeweney::Status
296+
297+
APP_ROOT = File.join(__dir__, 'app')
298+
299+
def make_request(*, **)
300+
req = mock_req(*, **)
301+
@app.call(req)
302+
req
303+
end
304+
305+
def test_app_dependencies
306+
foo = { foo: 'foo' }
307+
bar = { bar: 'bar' }
308+
309+
@machine = UM.new
310+
311+
@tmp_path = '/test/tmp'
312+
@tmp_fn = File.join(APP_ROOT, 'tmp.rb')
313+
314+
@app = Syntropy::App.new(
315+
root_dir: APP_ROOT,
316+
mount_path: '/test',
317+
machine: @machine,
318+
foo: foo,
319+
bar: bar
320+
)
321+
322+
req = make_request(':method' => 'GET', ':path' => '/test/bar')
323+
assert_equal 'foobar', req.response_body
324+
assert_equal Status::OK, req.response_status
325+
end
326+
end

0 commit comments

Comments
 (0)