From 0418d63b1286faf8d9baaf07c56631ddb46c4a76 Mon Sep 17 00:00:00 2001 From: Silvio Fricke Date: Mon, 29 Mar 2021 20:12:09 +0200 Subject: make: rework test strategy Signed-off-by: Silvio Fricke --- Makefile | 44 +++++++++++++++++++++++++++++++++++--------- 1 file changed, 35 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 0df63bf..11d6213 100644 --- a/Makefile +++ b/Makefile @@ -5,19 +5,45 @@ prepare: build: docker build -t silvio/docker-languagetool . -test: +test: test-cleanup.1 +test: TESTIPADDRESS=$(subst ",,$(shell docker inspect languagetool | jq '.[0].NetworkSettings.IPAddress')) +test: test-print-ip-address +test: test-start +test: test-run-test-lang +test: test-run-test-en +test: test-run-test-fr +test: test-cleanup.2 + +test-start: docker run -d --name languagetool -p 8010:8010 silvio/docker-languagetool - sleep 5 + sleep 3 + +test-print-ip-address: + @echo "IP address of languagetools docker container: $(TESTIPADDRESS)" + +test-run-test-lang: + curl \ + -X GET \ + --header 'Accept: application/json' \ + 'http://$(TESTIPADDRESS):8010/v2/languages' - echo "get all languages" - curl -X GET --header 'Accept: application/json' 'http://172.17.0.1:8010/v2/languages' +test-run-test-en: + curl \ + -X POST \ + --header 'Content-Type: application/x-www-form-urlencoded' \ + --header 'Accept: application/json' \ + -d 'text=hello%20woorld&language=en-US&motherTongue=de-DE&enabledOnly=false' \ + 'http://$(TESTIPADDRESS):8010/v2/check' - echo "test en-US" - curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d 'text=hello%20woorld&language=en-US&motherTongue=de-DE&enabledOnly=false' 'http://172.17.0.1:8010/v2/check' +test-run-test-fr: + curl -X POST \ + --header 'Content-Type: application/x-www-form-urlencoded' \ + --header 'Accept: application/json' \ + -d 'text=hello%20woorld&language=fr&motherTongue=de-DE&enabledOnly=false' \ + 'http://$(TESTIPADDRESS):8010/v2/check' - echo "test fr" - curl -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d 'text=hello%20woorld&language=fr&motherTongue=de-DE&enabledOnly=false' 'http://172.17.0.1:8010/v2/check' -stop: +.PHONY: test-cleanup +test-cleanup.%: docker stop languagetool docker rm languagetool -- cgit v1.2.3