integration test cleanup

This commit is contained in:
BuckarooBanzay 2020-04-21 14:06:24 +02:00
parent e9edb5be26
commit 9de2508803
3 changed files with 31 additions and 25 deletions

View File

@ -1,3 +1,4 @@
node_modules
test_mod
mail_mod
integration-test.sh

View File

@ -1,25 +1,29 @@
#!/bin/bash
# setup
unset use_proxy
unset http_proxy
unset https_proxy
unset HTTP_PROXY
unset HTTPS_PROXY
# build
docker build . -t mail
# run mail-server
docker run --name mail --rm \
-e WEBMAILKEY=myserverkey \
-e WEBMAIL_DEBUG=true \
--network host \
mail &
function cleanup {
# cleanup
docker stop mail
}
trap cleanup EXIT
# wait for startup
bash -c 'while !</dev/tcp/localhost/8080; do sleep 1; done;'
# clone mod-part
git clone https://github.com/minetest-mail/mail_mod.git
# configure minetest
CFG=/tmp/minetest.conf
MTDIR=/tmp/mt
WORLDDIR=${MTDIR}/worlds/world
@ -32,19 +36,32 @@ EOF
mkdir -p ${WORLDDIR}
chmod 777 ${MTDIR} -R
docker run --rm -i \
# start minetest with mail mod
docker run --rm --name minetest \
-v ${CFG}:/etc/minetest/minetest.conf:ro \
-v ${MTDIR}:/var/lib/minetest/.minetest \
-v $(pwd)/mail_mod:/var/lib/minetest/.minetest/worlds/world/worldmods/mail \
-v $(pwd)/test_mod:/var/lib/minetest/.minetest/worlds/world/worldmods/mail_test \
--network host \
registry.gitlab.com/minetest/minetest/server:5.2.0
registry.gitlab.com/minetest/minetest/server:5.2.0 &
test -f ${WORLDDIR}/integration_test.json && exit 0 || exit 1
# prepare cleanup
function cleanup {
# cleanup
docker stop mail
docker stop minetest
}
trap cleanup EXIT
# wait for startup
sleep 10
# Execute calls agains mail-server
# https://jwt.io/
# TODO
#TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwidXNlcm5hbWUiOiJkc3QiLCJpYXQiOjE1MTYyMzkwMjJ9.7ik564LuatEhOFapNWIqSlYcST41cgmHGAuTnAowTu8"
#curl -v -H "Authorization: ${TOKEN}" "http://127.0.0.1:8080/api/inbox"
TOKEN="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwidXNlcm5hbWUiOiJkc3QiLCJpYXQiOjE1MTYyMzkwMjJ9.7ik564LuatEhOFapNWIqSlYcST41cgmHGAuTnAowTu8"
curl -v -H "Authorization: ${TOKEN}" "http://127.0.0.1:8080/api/inbox"
echo "Test complete!"

View File

@ -4,16 +4,4 @@ minetest.log("warning", "[TEST] integration-test enabled!")
minetest.register_on_mods_loaded(function()
minetest.log("warning", "[TEST] starting tests")
mail.send("src", "dst", "subject", "body");
minetest.after(1, function()
minetest.log("warning", "[TEST] integration tests done!")
minetest.request_shutdown("success")
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
end)
end)