-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from ahoy-cli/dev-bats-tests
Add some tests using bats.
- Loading branch information
Showing
11 changed files
with
172 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
# Ignore the items build by sphinx for read the docs. | ||
docs/_build | ||
# Ignore the ahoy binary when it's built | ||
ahoy |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
ahoyapi: v2 | ||
commands: | ||
echo: | ||
cmd: echo {{args}} |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#!/usr/bin/env bats | ||
|
||
@test "get the version of ahoy with --version" { | ||
run ./ahoy -f testdata/simple.ahoy.yml --version | ||
[ $status -eq 0 ] | ||
[ $(expr "$output" : "[0-9.]\.[0-9.]\.[0-9.]") -ne 0 ] | ||
} | ||
|
||
@test "get help instead of running a command with --help" { | ||
result="$(./ahoy -f testdata/simple.ahoy.yml --help echo something)" | ||
[ "$result" != "something" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/usr/bin/env bats | ||
|
||
setup() { | ||
mv .ahoy.yml tmp.ahoy.yml | ||
} | ||
|
||
teardown() { | ||
mv tmp.ahoy.yml .ahoy.yml | ||
} | ||
|
||
@test "run ahoy without a command and without a .ahoy.yml file" { | ||
run ./ahoy | ||
[ $status -eq 1 ] | ||
[ "${lines[-2]}" == "[error] No .ahoy.yml found. You can use 'ahoy init' to download an example." ] | ||
[ "${lines[-1]}" == "[fatal] Missing flag or argument." ] | ||
} | ||
|
||
@test "run an ahoy command without a .ahoy.yml file" { | ||
run ./ahoy something | ||
[ "$output" == "[fatal] Command not found for 'something'" ] | ||
} | ||
|
||
@test "run ahoy init without a .ahoy.yml file" { | ||
run ./ahoy init | ||
[ "${lines[-1]}" == "example.ahoy.yml downloaded to the current directory. You can customize it to suit your needs!" ] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/usr/bin/env bats | ||
|
||
@test "display help text and fatal error when no arguments are passed." { | ||
run ./ahoy -f testdata/simple.ahoy.yml | ||
# Should throw an error. | ||
[ $status -ne 0 ] | ||
echo "$output" | ||
[ "${#lines[@]}" -gt 10 ] | ||
[ "${lines[-1]}" == "[fatal] Missing flag or argument." ] | ||
} | ||
|
||
@test "run a simple ahoy command: echo" { | ||
result="$(./ahoy -f testdata/simple.ahoy.yml echo something)" | ||
[ "$result" == "something" ] | ||
} |