diff options
| author | Hisham Muhammad <hisham@gobolinux.org> | 2017-10-08 01:57:17 -0300 |
|---|---|---|
| committer | Hisham Muhammad <hisham@gobolinux.org> | 2017-10-08 01:57:17 -0300 |
| commit | c5bcb900a8245845dd5cd4fd8bf796591769bbee (patch) | |
| tree | 5698699bfa3a2ae778324852249d0eeca8719d3e /test | |
| parent | feedb79595885c8f86ad412ef561f05664da7c14 (diff) | |
| download | luarocks-c5bcb900a8245845dd5cd4fd8bf796591769bbee.tar.gz luarocks-c5bcb900a8245845dd5cd4fd8bf796591769bbee.tar.bz2 luarocks-c5bcb900a8245845dd5cd4fd8bf796591769bbee.zip | |
Tests: use local fixture for new_version test.
Diffstat (limited to 'test')
| -rw-r--r-- | test/test_mock_server.lua | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/test/test_mock_server.lua b/test/test_mock_server.lua new file mode 100644 index 00000000..74a57b89 --- /dev/null +++ b/test/test_mock_server.lua | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | --- Utility module to launch the mock-server from within test spec files. | ||
| 2 | local test_mock_server = {} | ||
| 3 | |||
| 4 | local assert = require("luassert") | ||
| 5 | local test_env = require("test/test_environment") | ||
| 6 | local testing_paths = test_env.testing_paths | ||
| 7 | |||
| 8 | function test_mock_server.extra_rocks(more) | ||
| 9 | local rocks = { | ||
| 10 | -- rocks needed for mock-server | ||
| 11 | "/copas-2.0.1-1.src.rock", | ||
| 12 | "/coxpcall-1.16.0-1.src.rock", | ||
| 13 | "/dkjson-2.5-2.src.rock", | ||
| 14 | "/luafilesystem-1.6.3-1.src.rock", | ||
| 15 | "/luasec-0.6-1.rockspec", | ||
| 16 | "/luasocket-3.0rc1-2.src.rock", | ||
| 17 | "/luasocket-3.0rc1-2.rockspec", | ||
| 18 | "/restserver-0.1-1.src.rock", | ||
| 19 | "/restserver-xavante-0.2-1.src.rock", | ||
| 20 | "/rings-1.3.0-1.src.rock", | ||
| 21 | "/wsapi-1.6.1-1.src.rock", | ||
| 22 | "/wsapi-xavante-1.6.1-1.src.rock", | ||
| 23 | "/xavante-2.4.0-1.src.rock" | ||
| 24 | } | ||
| 25 | if more then | ||
| 26 | for _, rock in ipairs(more) do | ||
| 27 | table.insert(rocks, rock) | ||
| 28 | end | ||
| 29 | end | ||
| 30 | return rocks | ||
| 31 | end | ||
| 32 | |||
| 33 | function test_mock_server.init() | ||
| 34 | assert.is_true(test_env.need_rock("restserver-xavante")) | ||
| 35 | local final_command = test_env.execute_helper(testing_paths.lua .. " " .. testing_paths.testing_dir .. "/mock-server.lua &", true, test_env.env_variables) | ||
| 36 | os.execute(final_command) | ||
| 37 | end | ||
| 38 | |||
| 39 | function test_mock_server.done() | ||
| 40 | os.execute("curl localhost:8080/shutdown") | ||
| 41 | end | ||
| 42 | |||
| 43 | return test_mock_server | ||
