-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathexample-http.main.kts
executable file
·43 lines (37 loc) · 1.32 KB
/
example-http.main.kts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#!/usr/bin/env kotlin
// Uncomment to use mavenLocal. Run `./gradlew publishToMavenLocal -Pskip.signing=true`
//@file:Repository("file:///Users/username/.m2/repository/")
@file:DependsOn("com.shoprunner:baleen-script:1.14.1")
import com.shoprunner.baleen.*
import com.shoprunner.baleen.Baleen.describeAs
import com.shoprunner.baleen.printer.*
import com.shoprunner.baleen.script.*
import com.shoprunner.baleen.types.*
import java.io.File
val description = "person".describeAs {
"data".type {
"id".type(IntegerType(), required = true)
"first_name".type(StringType(0, 32), required = true)
"middle_name".type(AllowsNull(StringType(0, 32)))
"last_name".type(StringType(0, 32), required = true)
test("first name is not same as last name") { data ->
assertNotEquals(
"first != last",
data.getAsStringOrNull("first_name"),
data.getAsStringOrNull("last_name")
)
}
}
}
File("summary/example-http.html").writer().use {
validate(
description = description,
data = http(
url = "https://reqres.in/api/users/2",
method = Method.GET,
contentType = "application/json",
data = json()
),
printers = arrayOf(ConsolePrinter, HtmlPrinter(it)),
)
}