From d8a7d8bb09992533ef322ccec50a1fe28fc93d5c Mon Sep 17 00:00:00 2001 From: Alex Epstein Date: Thu, 9 Nov 2017 08:52:59 -0500 Subject: [PATCH] Bringing back stocks tests --- tests/stocks.bats | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 tests/stocks.bats diff --git a/tests/stocks.bats b/tests/stocks.bats new file mode 100755 index 0000000..f604706 --- /dev/null +++ b/tests/stocks.bats @@ -0,0 +1,44 @@ +#!/bin/env bats + +@test "Testing stocks tool" { + echo stocks +} + +@test "Check for latest version of bash-snippets on update" { + if [[ "$(uname)" == "Linux" ]];then + run stocks update + [ "$status" -eq 0 ] + [ "$output" = "Bash-Snippets is already the latest version" ] +fi +} + +@test "The -h option should print usage" { + run stocks -h + [ "$status" -eq 0 ] + [ "${lines[0]}" = "Stocks" ] +} + +@test "No arguments prints usage instructions" { + run stocks + [ "$status" -eq 0 ] + [ "${lines[0]}" = "Stocks" ] +} + +@test "Get stock info by passing in ticker" { + run stocks AAPL + [ "$status" -eq 0 ] + [ "${lines[0]}" = "AAPL stock info" ] +} + +@test "Get stock info by passing in company" { + run stocks Tesla + [ "$status" -eq 0 ] + [ "${lines[0]}" = "TSLA stock info" ] +} + +@test "Get the tools version with -v" { + run stocks -v + [ "$status" -eq 0 ] + result=$( echo $(stocks -v) | grep -Eo "Version") + [ "$result" = "Version" ] +}