#
HTTP Tests
#
Uptime Tests
The following is will make a GET request to https://synthetigo.dev and assert that the status code is 200, which can be used to check the basic uptime of a site.
resource "synthetigo_test" "this" resource "synthetigo_test" "this" {
name = "Some test name"
regions = ["uk"]
schedule = "* * * * *"
step {
name = "Simple HTTP"
kind = "http"
options = {
url = "https://synthetigo.dev"
timeout = "1s"
assertions = {
"response.code" = 200
}
}
}
}
#
API Tests
#
Simple
You can test APIs by crafting requests and checking responses:
resource "synthetigo_test" "this" resource "synthetigo_test" "this" {
name = "Some test name"
regions = ["uk"]
schedule = "* * * * *"
step {
name = "Simple API"
kind = "http"
options = {
url = "https://api.synthetigo.dev/demo"
method = "POST"
body = "{\"name\": \"demo\"}"
timeout = "250ms"
assertions = {
"response.code" = 200
"response.header.is" = [
"Content-Type == application/json"
]
"response.body.json.has" = [
"items.0",
"items.0.id"
]
}
}
}
}
#
Complex
You can chain requests together to simulate user journeys:
resource "synthetigo_test" "this" resource "synthetigo_test" "this" {
name = "Some test name"
regions = ["uk"]
schedule = "* * * * *"
step {
name = "Simple API"
kind = "http"
options = {
url = "https://api.synthetigo.dev/demo"
method = "POST"
body = "{\"name\": \"demo\"}"
timeout = "250ms"
assertions = {
"response.code" = 200
"response.header.is" = [
"Content-Type == application/json"
]
"response.body.json.has" = [
"items.0",
"items.0.id"
]
}
extracts = {
body = {
json = {
ITEM_ID = "items.0.id"
}
}
}
}
}
step {
name = "Check item status"
kind = "http"
options = {
url = "https://api.synthetigo.dev/demo/{{ .ITEM_ID }}"
method = "GET"
assertions = {
"response.code" = 200
"response.json.has" = [
"status"
]
"response.json.is" = [
"status == DELIVERED"
]
}
}
}
}