From f5632bffbee6ac103fe04fd281c490a7d4edd1a8 Mon Sep 17 00:00:00 2001 From: kleph Date: Tue, 3 Mar 2020 00:07:47 +0100 Subject: [PATCH 1/4] [CI] Add sample staging tests --- .drone.yml | 7 +++++++ staging_tests.sh | 22 ++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 staging_tests.sh diff --git a/.drone.yml b/.drone.yml index 70944ea..d7a1972 100644 --- a/.drone.yml +++ b/.drone.yml @@ -96,6 +96,13 @@ steps: exclude: - master +- name: test staging + image: ellerbrock/alpine-bash-curl-ssl + environment: + BRANCH: ${DRONE_COMMIT_BRANCH} + commands: + - bash staging_tests.sh + - name: deploy live image: sinlead/drone-kubectl settings: diff --git a/staging_tests.sh b/staging_tests.sh new file mode 100644 index 0000000..72e79f7 --- /dev/null +++ b/staging_tests.sh @@ -0,0 +1,22 @@ +if [ ${BRANCH} == 'master' ]; then + TEST_URL='http://beer.k3s.kleph.eu' +else + TEST_URL='http://staging.beer.k3s.kleph.eu' +fi + +CURL_OPTS='-s' +# default +curl ${CURL_OPTS} ${TEST_URL} | grep -q 'setHours( 17, 0);' +[ $? -ne 0 ] && exit 1 + +# set 1 parameter +hours=18 +curl ${CURL_OPTS} ${TEST_URL}/${hours} | grep -q "setHours( ${hours}, 0);" +[ $? -ne 0 ] && exit 1 + +# set 2 parameters +minutes=30 +curl ${CURL_OPTS} ${TEST_URL}/${hours}/${minutes} | grep -q "setHours( ${hours}, ${minutes});" +[ $? -ne 0 ] && exit 1 + +exit 0 From ff6c1f586e3b5aa5852775fa8ad0aeee0a9ec05b Mon Sep 17 00:00:00 2001 From: kleph Date: Tue, 3 Mar 2020 00:29:50 +0100 Subject: [PATCH 2/4] [tests] Test parameters passed in URL Fixes #7 --- tests/test_beer.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_beer.py b/tests/test_beer.py index 279dcf7..4ae8827 100644 --- a/tests/test_beer.py +++ b/tests/test_beer.py @@ -21,3 +21,16 @@ def test_slash(client): response = client.get('/') assert response.status_code == 200 assert b'beer' in response.data + +def test_parameters(client): + """Test wiwth no param""" + + hours = '18' + minutes = '30' + response = client.get('/'+hours) + assert response.status_code == 200 + assert b'beer' in response.data + + response = client.get('/'+hours+'/'+minutes) + assert response.status_code == 200 + assert b'beer' in response.data From fdc5423a8d57a16c242ef20ccde38cce1daf8801 Mon Sep 17 00:00:00 2001 From: kleph Date: Tue, 3 Mar 2020 00:07:47 +0100 Subject: [PATCH 3/4] [CI] Add sample staging tests --- staging_tests.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/staging_tests.sh b/staging_tests.sh index 7bc1707..f5ac9af 100644 --- a/staging_tests.sh +++ b/staging_tests.sh @@ -4,6 +4,7 @@ else TEST_URL='http://staging.beer.k3s.kleph.eu' fi echo "testing URL: ${TEST_URL}" + CURL_OPTS='-s' # default curl ${CURL_OPTS} ${TEST_URL} | grep -q 'setHours( 17, 0);' From d167fe1b52751b9b8795e107d2012791bdd2c4f0 Mon Sep 17 00:00:00 2001 From: kleph Date: Tue, 3 Mar 2020 00:29:50 +0100 Subject: [PATCH 4/4] [tests] Test parameters passed in URL Fixes #7 --- tests/test_beer.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/test_beer.py b/tests/test_beer.py index 279dcf7..4ae8827 100644 --- a/tests/test_beer.py +++ b/tests/test_beer.py @@ -21,3 +21,16 @@ def test_slash(client): response = client.get('/') assert response.status_code == 200 assert b'beer' in response.data + +def test_parameters(client): + """Test wiwth no param""" + + hours = '18' + minutes = '30' + response = client.get('/'+hours) + assert response.status_code == 200 + assert b'beer' in response.data + + response = client.get('/'+hours+'/'+minutes) + assert response.status_code == 200 + assert b'beer' in response.data