Skip to content

Commit

Permalink
Add testing workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
p3k committed Feb 10, 2024
1 parent 8351703 commit 25d720d
Show file tree
Hide file tree
Showing 2 changed files with 76 additions and 0 deletions.
21 changes: 21 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Run tests

on:
push

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
python-version: [3.x]

steps:
- uses: actions/checkout@v4

- run: |
make install
make server &
#sh ./test.sh
kill %1
55 changes: 55 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
#!/usr/bin/env sh

curl='curl --get --silent --verbose'
base_url='http://localhost:8000'
http_bin_url=https://httpbin.org/status/200

# Test Roxy

response=$($curl --data-urlencode "url=$http_bin_url" "$base_url/roxy")

# Test Roxy status
test "$(
echo "$response" | jq '.headers["X-Roxy-Status"]'
)" = 200 || exit 1

# Test Roxy URL
test "$(
echo "$response" | jq --raw-output '.headers["X-Roxy-Url"]'
)" = "$http_bin_url" || exit 1

# Test JSONP output
test "$(
$curl --data-urlencode "url=$http_bin_url" "$base_url/roxy?callback=evaluate" | sed --quiet '/^evaluate(.*)$/p'
)" || exit 1

# Test Ferris

group=unit-tests

# Be sure the group is empty
$curl "$base_url/tasks/ferris?group=$group" > /dev/null

# This curl adds a URL to the group
ferris_curl="$curl --get --data-urlencode 'url=http://host.dom' '$base_url/ferris?group=$group'"

# Send the curl request, then there should be one item more – rinse and repeat
test "$(eval "$ferris_curl" | xargs)" = 1
test "$(eval "$ferris_curl" | xargs)" = 2
test "$(eval "$ferris_curl" | xargs)" = 3

# Verify the data
response=$($curl --get "$base_url/ferris?group=$group")

# The first item should have the added URL
test "$(
echo "$response" | jq --raw-output .[0].url
)" = 'http://host.dom' || exit 1

# The first item should have 3 hits
test "$(
echo "$response" | jq .[0].hits
)" = 3 || exit 1

# Clean up
$curl "$base_url/tasks/ferris?group=$group" > /dev/null

0 comments on commit 25d720d

Please sign in to comment.