add (simple) integration test
This commit is contained in:
parent
8c6e435e8a
commit
7437cb58a7
14
.github/workflows/integration-test.yml
vendored
Normal file
14
.github/workflows/integration-test.yml
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
name: integration-test
|
||||
|
||||
on: [push, pull_request]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v1
|
||||
|
||||
- name: integration-test
|
||||
run: ./integration-test.sh
|
5
init.lua
5
init.lua
@ -79,4 +79,9 @@ if minetest.settings:get_bool("beerchat.enable_jail") then
|
||||
dofile(MP.."/jail.lua")
|
||||
end
|
||||
|
||||
if minetest.settings:get_bool("enable_beerchat_integration_test") then
|
||||
dofile(MP.."/integration_test.lua")
|
||||
end
|
||||
|
||||
|
||||
print("[OK] beerchat")
|
||||
|
21
integration-test.sh
Executable file
21
integration-test.sh
Executable file
@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
# simple integration test
|
||||
|
||||
CFG=/tmp/minetest.conf
|
||||
MTDIR=/tmp/mt
|
||||
WORLDDIR=${MTDIR}/worlds/world
|
||||
|
||||
cat <<EOF > ${CFG}
|
||||
enable_beerchat_integration_test = true
|
||||
secure.http_mods = beerchat
|
||||
EOF
|
||||
|
||||
mkdir -p ${WORLDDIR}
|
||||
chmod 777 ${MTDIR} -R
|
||||
docker run --rm -i \
|
||||
-v ${CFG}:/etc/minetest/minetest.conf:ro \
|
||||
-v ${MTDIR}:/var/lib/minetest/.minetest \
|
||||
-v $(pwd):/var/lib/minetest/.minetest/worlds/world/worldmods/beerchat \
|
||||
registry.gitlab.com/minetest/minetest/server:5.2.0
|
||||
|
||||
test -f ${WORLDDIR}/integration_test.json && exit 0 || exit 1
|
19
integration_test.lua
Normal file
19
integration_test.lua
Normal file
@ -0,0 +1,19 @@
|
||||
|
||||
minetest.log("warning", "[TEST] integration-test enabled!")
|
||||
|
||||
minetest.register_on_mods_loaded(function()
|
||||
minetest.after(1, function()
|
||||
|
||||
-- TODO something useful here
|
||||
|
||||
local data = minetest.write_json({ success = true }, true);
|
||||
local file = io.open(minetest.get_worldpath().."/integration_test.json", "w" );
|
||||
if file then
|
||||
file:write(data)
|
||||
file:close()
|
||||
end
|
||||
|
||||
minetest.log("warning", "[TEST] integration tests done!")
|
||||
minetest.request_shutdown("success")
|
||||
end)
|
||||
end)
|
Loading…
x
Reference in New Issue
Block a user