Skip to content

Commit

Permalink
Use Hurl for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddewie committed Jul 14, 2024
1 parent cbb168e commit 2e26944
Show file tree
Hide file tree
Showing 4 changed files with 127 additions and 195 deletions.
9 changes: 8 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,13 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Install Hurl
env:
VERSION: '4.3.0'
run: |
curl --location --remote-name https://github.com/Orange-OpenSource/hurl/releases/download/$VERSION/hurl_${VERSION}_amd64.deb
sudo apt update && sudo apt install ./hurl_${VERSION}_amd64.deb
- name: Get Date
id: get-date
shell: bash
Expand Down Expand Up @@ -57,4 +64,4 @@ jobs:
- name: Run API tests
working-directory: api
run: |
python3 tests/tests.py --api http://localhost:5000/api --tests tests/testcases.yml
hurl --test --verbose --variable base_url=http://localhost:5000/api test/api.hurl
119 changes: 119 additions & 0 deletions api/tests/api.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Facility request
GET {{base_url}}/facility
[QueryStringParams]
name: Berlin
HTTP 200
Content-Type: application/json
[Asserts]
jsonpath "$" count == 20
jsonpath "$[0].name" == "Berlin Südkreuz"
jsonpath "$[1].name" == "Berlin-Spandau"
jsonpath "$[2].name" == "Berlin Gesundbrunnen"
jsonpath "$[3].name" == "Berlin Ostbahnhof"
jsonpath "$[4].name" == "Berlin Hauptbahnhof"
jsonpath "$[5].name" == "Ostkreuz"
jsonpath "$[6].name" == "Berlin Potsdamer Platz"
jsonpath "$[7].name" == "Warschauer Straße"
jsonpath "$[8].name" == "Bornholmer Straße"
jsonpath "$[9].name" == "Baumschulenweg"
jsonpath "$[10].name" == "Schöneweide"
jsonpath "$[11].name" == "Alexanderplatz"
jsonpath "$[12].name" == "Gesundbrunnen"
jsonpath "$[13].name" == "Berlin Alexanderplatz"
jsonpath "$[14].name" == "Berlin Zoologischer Garten"
jsonpath "$[15].name" == "Zoologischer Garten"
jsonpath "$[16].name" == "Ostbahnhof"
jsonpath "$[17].name" == "Westkreuz"
jsonpath "$[18].name" == "Brandenburger Tor"
jsonpath "$[19].name" == "Berlin Friedrichstraße"

# Facility request with limit
GET {{base_url}}/facility
[QueryStringParams]
name: Berlin
limit: 5
HTTP 200
[Asserts]
jsonpath "$" count == 5

# Facility request with larger limit
GET {{base_url}}/facility
[QueryStringParams]
name: Berlin
limit: 25
HTTP 200
[Asserts]
jsonpath "$" count == 25

# TODO request with too large limit

# Facility request with hyphen
GET {{base_url}}/facility
[QueryStringParams]
name: Berlin-Spandau
HTTP 200
[Asserts]
jsonpath "$" count == 7
jsonpath "$[0].name" == "Berlin-Spandau"
jsonpath "$[1].name" == "Spandau"
jsonpath "$[2].name" == "Berlin-Spandau Gbf"
jsonpath "$[3].name" == "Berlin-Spandau West"
jsonpath "$[4].name" == "Berlin-Spandau Mitte"
jsonpath "$[5].name" == "Berlin-Spandau Ost"
jsonpath "$[6].name" == "Berlin-Spandau Johannesstift"

# Facility request with space
GET {{base_url}}/facility
[QueryStringParams]
name: Berlin Spandau
HTTP 200
[Asserts]
jsonpath "$" count == 7
jsonpath "$[0].name" == "Berlin-Spandau"
jsonpath "$[1].name" == "Spandau"
jsonpath "$[2].name" == "Berlin-Spandau Gbf"
jsonpath "$[3].name" == "Berlin-Spandau West"
jsonpath "$[4].name" == "Berlin-Spandau Mitte"
jsonpath "$[5].name" == "Berlin-Spandau Ost"
jsonpath "$[6].name" == "Berlin-Spandau Johannesstift"

# Facility request for Spandau
GET {{base_url}}/facility
[QueryStringParams]
name: Spandau
HTTP 200
[Asserts]
jsonpath "$" count == 9
jsonpath "$[0].name" == "Berlin-Spandau"
jsonpath "$[1].name" == "Spandau"
jsonpath "$[2].name" == "Altstadt Spandau"
jsonpath "$[3].name" == "Rathaus Spandau"
jsonpath "$[4].name" == "Berlin-Spandau Gbf"
jsonpath "$[5].name" == "Berlin-Spandau West"
jsonpath "$[6].name" == "Berlin-Spandau Mitte"
jsonpath "$[7].name" == "Berlin-Spandau Ost"
jsonpath "$[8].name" == "Berlin-Spandau Johannesstift"

# Facility request with with diacritics
GET {{base_url}}/facility
[QueryStringParams]
name: Karl-Marx-Straße
HTTP 200
[Asserts]
jsonpath "$" count == 1
jsonpath "$[0].name" == "Karl-Marx-Straße"

# TODO facility request with q query
# TODO facility request with UIC queries

# Milestone request for line 6020 milestone 22.7
GET {{base_url}}/milestone
[QueryStringParams]
ref: 6020
position: 22.7
limit: 1
HTTP 200
[Asserts]
jsonpath "$" count == 1
jsonpath "$[0].ref" == "6020"
jsonpath "$[0].position" == 22.7
106 changes: 0 additions & 106 deletions api/tests/testcases.yml

This file was deleted.

88 changes: 0 additions & 88 deletions api/tests/tests.py

This file was deleted.

0 comments on commit 2e26944

Please sign in to comment.