Skip to content

Commit 51ba879

Browse files
committed
✅ Add tests
1 parent 94770dd commit 51ba879

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

tests/api-to-go.bats

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,42 @@ teardown(){
2929
run eval "$COMMAND"
3030
[ "$status" -eq 0 ]
3131
}
32+
33+
@test "Command with custom headers" {
34+
HEADERS='{"Content-Type": "application/json"}'
35+
COMMAND="$API_TO_GO --headers '$HEADERS' $BASE_URL/todos/1"
36+
run eval "$COMMAND"
37+
[ "$status" -eq 0 ]
38+
}
39+
40+
@test "Command with POST method" {
41+
DATA='{"title": "foo", "body": "bar", "userId": 1}'
42+
COMMAND="$API_TO_GO --method POST $BASE_URL/posts '$DATA'"
43+
run eval "$COMMAND"
44+
[ "$status" -eq 0 ]
45+
}
46+
47+
@test "Command with GET method" {
48+
COMMAND="$API_TO_GO --method GET $BASE_URL/posts/1"
49+
run eval "$COMMAND"
50+
[ "$status" -eq 0 ]
51+
}
52+
53+
@test "Debug mode activation" {
54+
COMMAND="$API_TO_GO -D $BASE_URL/posts"
55+
run eval "$COMMAND"
56+
[ "$status" -eq 0 ]
57+
}
58+
59+
@test "Display help message" {
60+
COMMAND="$API_TO_GO --help"
61+
run eval "$COMMAND"
62+
[ "$status" -eq 0 ]
63+
[ "${lines[0]}" = "Usage: api-to-go [options] <url> [body]" ]
64+
}
65+
66+
@test "Display version information" {
67+
COMMAND="$API_TO_GO --version"
68+
run eval "$COMMAND"
69+
[ "$status" -eq 0 ]
70+
}

0 commit comments

Comments
 (0)