Skip to content

Commit

Permalink
feat(examples): add todo API tests and enhance existing examples
Browse files Browse the repository at this point in the history
  • Loading branch information
jellydn committed Oct 31, 2024
1 parent 51c2f91 commit 98dd5d6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
1 change: 1 addition & 0 deletions example/dogs.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ HTTP 200

[Captures]
id: jsonpath "$.data[0].id"
name: jsonpath "$.data[0].attributes.name"

GET https://dogapi.dog/api/v2/breeds/{{id}}

Expand Down
4 changes: 2 additions & 2 deletions example/example.hurl
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ header "server" contains "MangaDex"

GET https://google.com

HTTP 301
HTTP 302
[Asserts]
xpath "string(//title)" == "301 Moved"
xpath "string(//title)" == "302 Moved"

GET https://www.google.com

Expand Down
25 changes: 25 additions & 0 deletions example/todo.hurl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Get all todos
GET https://wattpm-demo.fly.dev/express/api/todo

HTTP 200
[Asserts]
jsonpath "$.status" == "success"
header "server" contains "Fly"


# Throw error if text is not provided
POST https://wattpm-demo.fly.dev/express/api/todo
Content-Type: application/json
{}
HTTP 400
[Asserts]
jsonpath "$.status" == "error"
jsonpath "$.message" == "Text is required"

# Create a new todo
POST https://wattpm-demo.fly.dev/express/api/todo
Content-Type: application/json
{
"text": "Call Express API from hurl.nvim at {{now}}"
}
HTTP 201

0 comments on commit 98dd5d6

Please sign in to comment.