2017-07-09 08:02:30 +02:00
|
|
|
#!/bin/env bats
|
|
|
|
|
2018-07-29 03:00:42 +02:00
|
|
|
@test "Testing stocks tool" {
|
|
|
|
echo stocks
|
2017-07-09 08:02:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "Check for latest version of bash-snippets on update" {
|
2017-08-02 08:05:17 +02:00
|
|
|
if [[ "$(uname)" == "Linux" ]];then
|
2018-07-29 03:00:42 +02:00
|
|
|
run stocks update
|
2017-07-09 08:02:30 +02:00
|
|
|
[ "$status" -eq 0 ]
|
|
|
|
[ "$output" = "Bash-Snippets is already the latest version" ]
|
2017-08-02 08:05:17 +02:00
|
|
|
fi
|
2017-07-09 08:02:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "The -h option should print usage" {
|
2018-07-29 03:00:42 +02:00
|
|
|
run stocks -h
|
2017-07-09 08:02:30 +02:00
|
|
|
[ "$status" -eq 0 ]
|
2018-07-29 03:00:42 +02:00
|
|
|
[ "${lines[0]}" = "Stocks" ]
|
2017-07-09 08:02:30 +02:00
|
|
|
}
|
|
|
|
|
2018-07-29 03:00:42 +02:00
|
|
|
@test "No arguments prints usage instructions" {
|
|
|
|
run stocks
|
2017-07-09 08:02:30 +02:00
|
|
|
[ "$status" -eq 0 ]
|
2018-07-29 03:00:42 +02:00
|
|
|
[ "${lines[0]}" = "Stocks" ]
|
2017-07-09 08:02:30 +02:00
|
|
|
}
|
|
|
|
|
2018-07-29 03:00:42 +02:00
|
|
|
@test "Get stock info by passing in ticker" {
|
|
|
|
result=$( echo $(stocks AAPL) | grep -Eo "AAPL stock info" )
|
|
|
|
[ "$result" = "AAPL stock info" ]
|
|
|
|
|
|
|
|
}
|
2017-07-09 08:02:30 +02:00
|
|
|
|
2018-07-29 03:00:42 +02:00
|
|
|
@test "Get stock info by passing in company" {
|
|
|
|
result=$( echo $(stocks Apple) | grep -Eo "AAPL stock info" )
|
|
|
|
[ "$result" = "AAPL stock info" ]
|
2017-07-09 08:02:30 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
@test "Get the tools version with -v" {
|
2018-07-29 03:00:42 +02:00
|
|
|
run stocks -v
|
2017-07-09 08:02:30 +02:00
|
|
|
[ "$status" -eq 0 ]
|
2018-07-29 03:00:42 +02:00
|
|
|
result=$( echo $(stocks -v) | grep -Eo "Version")
|
2017-07-09 08:02:30 +02:00
|
|
|
[ "$result" = "Version" ]
|
|
|
|
}
|