Skip to content
Snippets Groups Projects
Commit a0dd94d5 authored by BuckarooBanzay's avatar BuckarooBanzay
Browse files

add integration test

parent c8bf0874
No related branches found
No related tags found
No related merge requests found
name: integration-test
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@master
- name: integration-test
run: ./test/integration-test.sh
Mail mod for Minetest (ingame mod) Mail mod for Minetest (ingame mod)
====== ======
![](https://github.com/minetest-mail/mail_mod/workflows/integration-test/badge.svg)
![](https://github.com/minetest-mail/mail_mod/workflows/luacheck/badge.svg)
This is a fork of cheapies mail mod This is a fork of cheapies mail mod
It adds a mail-system that allows players to send each other messages in-game and via webmail (optional) It adds a mail-system that allows players to send each other messages in-game and via webmail (optional)
......
#!/bin/bash
MINETEST_VERSION=5.2.0
# prerequisites
jq --version || exit 1
curl --version || exit 1
# ensure proper current directory
CWD=$(dirname $0)
cd ${CWD}
# setup
unset use_proxy
unset http_proxy
unset https_proxy
unset HTTP_PROXY
unset HTTPS_PROXY
# run mail-server
docker pull minetestmail/mail
docker run --name mail --rm \
-e WEBMAILKEY=myserverkey \
-e WEBMAIL_DEBUG=true \
--network host \
minetestmail/mail &
# wait for startup
bash -c 'while !</dev/tcp/localhost/8080; do sleep 1; done;'
# start minetest with mail mod
docker pull registry.gitlab.com/minetest/minetest/server:${MINETEST_VERSION}
docker run --rm --name minetest \
-u root:root \
-v $(pwd)/minetest.conf:/etc/minetest/minetest.conf:ro \
-v $(pwd)/world.mt:/root/.minetest/worlds/world/world.mt \
-v $(pwd)/auth.sqlite:/root/.minetest/worlds/world/auth.sqlite \
-v $(pwd)/../:/root/.minetest/worlds/world/worldmods/mail \
-v $(pwd)/test_mod:/root/.minetest/worlds/world/worldmods/mail_test \
-e use_proxy=false \
-e http_proxy= \
-e HTTP_PROXY= \
--network host \
registry.gitlab.com/minetest/minetest/server:${MINETEST_VERSION} &
# prepare cleanup
function cleanup {
# cleanup
docker stop mail
docker stop minetest
}
trap cleanup EXIT
# wait for startup
sleep 5
# Execute calls against mail-server
# login
LOGIN_DATA='{"username":"test","password":"enter"}'
RES=$(curl --data "${LOGIN_DATA}" -H "Content-Type: application/json" "http://127.0.0.1:8080/api/login")
echo Login response: $RES
SUCCESS=$(echo $RES | jq -r .success)
TOKEN=$(echo $RES | jq -r .token)
# login succeeded
test "$SUCCESS" == "true" || exit 1
# token extracted
test -n "$TOKEN" || exit 1
# fetch mails
RES=$(curl -H "Authorization: ${TOKEN}" "http://127.0.0.1:8080/api/inbox")
echo Mailbox: ${RES}
# inbox count is 1
test "$(echo $RES | jq '. | length')" == "1" || exit 1
echo "Test complete!"
minetest.log("warning", "[TEST] integration-test enabled!")
minetest.register_on_mods_loaded(function()
minetest.log("warning", "[TEST] starting tests")
mail.send("spammer", "test", "subject", "body");
end)
name = mail_test
depends = mail
enable_damage = true
creative_mode = false
gameid = minetest
auth_backend = sqlite3
backend = sqlite3
player_backend = sqlite3
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment