Skip to content

Instantly share code, notes, and snippets.

Avatar
🐾
Doing what I love to do!

Iván Corrales Solera ivancorrales

🐾
Doing what I love to do!
View GitHub Profile
View signUp-failures.hcl
scenario "a user registration fails because required fields are not provcided" {
examples = [
{ fullName ="", username = "", password =""},
{ fullName ="Jane Doe", username = "", password =""},
{ fullName ="Jane Doe", username = "jane@mail.com", password =""},
{ fullName ="Jane Doe", username = "", password ="secret"},
]
when "register the user" {
View happyPath.hcl
scenario "happy path" {
given "my user details" {
set user {
value = {
fullName = "John Smith"
username = "john.smith@mail.com"
password = "secret"
}
}
}
View main.hcl
description = <<EOF
This feature verify that API works as expected
EOF
includes = [
"includes/database.hcl",
"includes/api.hcl",
"happyPath.hcl",
"signUp-failures.hcl",
"signIn-failures.hcl",
View database.hcl
func dropCollection {
input {
arg mongoUri {
description = "mongo uri"
}
arg database {
description = "Name of the database"
default = "admin"
View api.hcl
vars {
mediaJson = "application/json"
}
func signUp {
input {
arg baseApi {
description = "URL base of the API"
}
arg user {
View scenario-mult.hcl
# scenario-mult.hcl
scenario "operation multiplication" {
examples = [
{ x = 20, y = 10, multResult= 200},
{ x = -1, y = -2, multResult= 2},
{ x = 5, y = 5, multResult= 25},
{ x = 5, y = 0, multResult= 0},
]
given "initialie result" {
set result {
View scenario-sub.hcl
# scenario-sub.hcl
scenario "operation substract" {
examples = [
{ x = 20, y = 10, subResult= 10},
{ x = 10, y = 20, subResult= 10},
{ x = 5, y = 5, subResult= 0},
]
when "subtract y to x" {
set result {
value = x - y
View scenario-sum.hcl
# scenario-sum.hcl
scenario "operation add" {
when "values are added" {
set result {
value = x + y
}
}
then "the result of the operation is the expected" {
assert {
assertion = result==sumResult
View vars-math-operations.hcl
# variables-math-operations.hcl
x = 46
y = 54
sumResult = 100
subResult = 8
View feature-math-operations.hcl
# feature-math-operations.hcl
description = <<EOF
This feature is used to demonstrate that both add and subs
operations work as expected.
EOF
input {
arg x {
default = 10
}
arg y {