From f5632bffbee6ac103fe04fd281c490a7d4edd1a8 Mon Sep 17 00:00:00 2001 From: kleph Date: Tue, 3 Mar 2020 00:07:47 +0100 Subject: [PATCH 1/2] [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/2] [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