Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* ✅ 💚 fix shebang in tests It was `#!/bin/env` now `#!/usr/bin/env`. The [travis config](.travis.yml) masked this by calling `bats` on the `./tests` directory. * ✅ fix: revert `cheats.bats` It was incorrectly overwritten with content of `stocks.bat`. * ✅ add bats boilerplate test file - [x] 🍱 add `skeleton.bats` boilerplate test file - [x] 🔨 refactor cheat.bats from new bats boilerplate - [x] ✏️ fix typo in `skeleton` * 💬 bump version tag in bak2dvd to match repo - [x] 🔨 refactor `bak2dvd.bats` from new bats boilerplate * 👽 update weather test due to external change wttr returns "Paramus" and not "Paramus, United States of America" as it did previously. * 💚 🍎 fix taste test - [x] 🔨 refactor `taste.bats` from new bats boilerplate * ✅ 💚 🍎 🐧 fix bats output checks - [x] ✅ 💚 update skeleton.bats - [x] 🍎 fix regex comparisons in bash 3.2 - [x] ✅ refactor bak2dvd, cheat, taste, short, weather - [x] ✅ 💚 add url tests to short.bats * Update weather.bats to cover no input params
- Loading branch information
1 parent
a3ba107
commit 4c899d8
Showing
22 changed files
with
422 additions
and
138 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
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,79 @@ | ||
#!/usr/bin/env bats | ||
|
||
export TOOL_NAME='skeleton' | ||
|
||
setup() { | ||
# $REPO_DIR/tests/skeleton.bats | ||
REPO_DIR="$( cd "$( dirname "${BATS_TEST_DIRNAME}")" >/dev/null 2>&1 && pwd)" | ||
TOOL_DIR="$( cd "${REPO_DIR}/${TOOL_NAME}" >/dev/null 2>&1 && pwd)" | ||
} | ||
|
||
@test "Testing ${TOOL_NAME} tool" { | ||
echo "${TOOL_NAME}" | ||
} | ||
|
||
@test "Confirm the \$REPO_DIR variable is evaluated" { | ||
cd "${REPO_DIR}" && pwd | ||
[[ "$status" -eq 0 ]] | ||
} | ||
|
||
@test "Change into the tool directory for ${TOOL_NAME}" { | ||
cd "${TOOL_DIR}" && pwd | ||
[[ "$status" -eq 0 ]] | ||
} | ||
|
||
@test "Check for latest version of bash-snippets on update" { | ||
if [[ "$(uname)" == "Linux" ]]; then | ||
run "${TOOL_DIR}/${TOOL_NAME}" update | ||
[[ "$status" -eq 0 ]] | ||
[ "$output" == "Bash-Snippets is already the latest version" ] | ||
fi | ||
} | ||
|
||
@test "The -h option should print usage" { | ||
run "${TOOL_DIR}/${TOOL_NAME}" -h | ||
[[ "$status" -eq 0 ]] | ||
# if bash is less than 7 yrs old | ||
if ((${BASH_VERSINFO[0]} >= 4)); then | ||
[[ "${lines[0]}" = "${TOOL_NAME^}" ]] | ||
else | ||
# or im probably a stoneage mac | ||
[[ "$(echo "${output}" | grep -i "${TOOL_NAME}")" ]] | ||
fi | ||
} | ||
|
||
@test "No arguments prints usage instructions" { | ||
run "${TOOL_DIR}/${TOOL_NAME}" | ||
[[ "$status" -eq 0 ]] | ||
# if bash is less than 7 yrs old | ||
if ((${BASH_VERSINFO[0]} >= 4)); then | ||
[[ "${lines[0]}" = "${TOOL_NAME^}" ]] | ||
else | ||
# or im probably a stoneage mac | ||
[[ "$(echo "${output}" | grep -i "${TOOL_NAME}")" ]] | ||
fi | ||
} | ||
|
||
@test "Get the tools version with -v" { | ||
run "${TOOL_DIR}/${TOOL_NAME}" -v | ||
[[ "$status" -eq 0 ]] | ||
expected='Version' | ||
[[ "${output}" =~ "${expected}" ]] | ||
} | ||
|
||
|
||
# Tool specific tests | ||
@test "Do that cool thing" { | ||
run "${TOOL_DIR}/${TOOL_NAME}" cool | ||
[[ "$status" -eq 0 ]] | ||
expected='This is awesome' | ||
[[ "${output}" =~ "${expected}" ]] | ||
} | ||
|
||
@test "Testing coolness factor" { | ||
run "${TOOL_DIR}/${TOOL_NAME}" cool --even-cooler | ||
[[ "$status" -eq 0 ]] | ||
expected='subzero' | ||
[[ "printf '%s\n' ${lines[1]}" =~ "${expected}" ]] | ||
} | ||
|
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,30 +1,72 @@ | ||
#!/bin/env bats | ||
#!/usr/bin/env bats | ||
# | ||
export TOOL_NAME='bak2dvd' | ||
|
||
@test "Testing bak2dvd tool" { | ||
echo bak2dvd | ||
setup() { | ||
# $REPO_DIR/tests/bak2dvd.bats | ||
REPO_DIR="$( cd "$( dirname "${BATS_TEST_DIRNAME}")" >/dev/null 2>&1 && pwd)" | ||
TOOL_DIR="$( cd "${REPO_DIR}/${TOOL_NAME}" >/dev/null 2>&1 && pwd)" | ||
} | ||
|
||
@test "Testing ${TOOL_NAME} tool" { | ||
echo "${TOOL_NAME}" | ||
} | ||
|
||
@test "Confirm the \$REPO_DIR variable is evaluated" { | ||
cd "${REPO_DIR}" && pwd | ||
|
||
[[ "$status" -eq 0 ]] | ||
} | ||
|
||
# can cd into script dir | ||
@test "Confirm a valid directory for ${TOOL_NAME}" { | ||
cd "${TOOL_DIR}" && pwd | ||
|
||
[[ "$status" -eq 0 ]] | ||
} | ||
|
||
@test "Check for latest version of bash-snippets on update" { | ||
if [[ "$(uname)" == "Linux" ]];then | ||
run bak2dvd update | ||
[ "$status" -eq 0 ] | ||
[ "$output" = "Bash-Snippets is already the latest version" ] | ||
fi | ||
if [[ "$(uname)" == "Linux" ]]; then | ||
run "${TOOL_DIR}/${TOOL_NAME}" update | ||
|
||
[[ "$status" -eq 0 ]] | ||
[ "$output" == "Bash-Snippets is already the latest version" ] | ||
fi | ||
} | ||
|
||
@test "The -h option should print usage" { | ||
if [[ "$(uname)" == "Linux" ]];then | ||
run bak2dvd -h | ||
[ "$status" -eq 0 ] | ||
[ "${lines[0]}" = "Bak2dvd" ] | ||
run "${TOOL_DIR}/${TOOL_NAME}" -h | ||
|
||
[[ "$status" -eq 0 ]] | ||
# if bash is less than 7 yrs old | ||
if ((${BASH_VERSINFO[0]} >= 4)); then | ||
[[ "${lines[0]}" = "${TOOL_NAME^}" ]] | ||
else | ||
# or im probably a stoneage mac | ||
[[ "$(echo "${output}" | grep -i "${TOOL_NAME}")" ]] | ||
fi | ||
} | ||
|
||
|
||
@test "No arguments prints usage instructions" { | ||
run "${TOOL_DIR}/${TOOL_NAME}" | ||
|
||
[[ "$status" -eq 0 ]] | ||
# if bash is less than 7 yrs old | ||
if ((${BASH_VERSINFO[0]} >= 4)); then | ||
[[ "${lines[0]}" = "${TOOL_NAME^}" ]] | ||
else | ||
# or im probably a stoneage mac | ||
[[ "$(echo "${output}" | grep -i "${TOOL_NAME}")" ]] | ||
fi | ||
} | ||
|
||
@test "Get the tools version with -v" { | ||
run bak2dvd -v | ||
[ "$status" -eq 0 ] | ||
result=$( echo $(bak2dvd -v) | grep -Eo "Version") | ||
[ "$result" = "Version" ] | ||
run "${TOOL_DIR}/${TOOL_NAME}" -v | ||
|
||
[[ "$status" -eq 0 ]] | ||
expected='Version' | ||
[[ "${output}" =~ "${expected}" ]] | ||
} | ||
|
||
# Tool specific tests | ||
|
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,43 +1,81 @@ | ||
#!/bin/env bats | ||
#!/usr/bin/env bats | ||
|
||
@test "Testing stocks tool" { | ||
echo stocks | ||
export TOOL_NAME='cheat' | ||
|
||
setup() { | ||
# $REPO_DIR/tests/tool.bats | ||
REPO_DIR="$( cd "$( dirname "${BATS_TEST_DIRNAME}")" >/dev/null 2>&1 && pwd)" | ||
TOOL_DIR="$( cd "${REPO_DIR}/${TOOL_NAME}" >/dev/null 2>&1 && pwd)" | ||
} | ||
|
||
@test "Testing ${TOOL_NAME} tool" { | ||
echo "${TOOL_NAME}" | ||
} | ||
|
||
@test "Confirm the \$REPO_DIR variable is evaluated" { | ||
cd "${REPO_DIR}" && pwd | ||
|
||
[[ "$status" -eq 0 ]] | ||
} | ||
|
||
# can cd into script dir | ||
@test "Confirm a valid directory for ${TOOL_NAME}" { | ||
cd "${TOOL_DIR}" && pwd | ||
|
||
[[ "$status" -eq 0 ]] | ||
} | ||
|
||
@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 | ||
if [[ "$(uname)" == "Linux" ]]; then | ||
run "${TOOL_DIR}/${TOOL_NAME}" 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" ] | ||
run "${TOOL_DIR}/${TOOL_NAME}" -h | ||
|
||
[[ "$status" -eq 0 ]] | ||
# if bash is less than 7 yrs old | ||
if ((${BASH_VERSINFO[0]} >= 4)); then | ||
[[ "${lines[0]}" = "${TOOL_NAME^}" ]] | ||
else | ||
# or im probably a stoneage mac | ||
[[ "$(echo "${output}" | grep -i "${TOOL_NAME}")" ]] | ||
fi | ||
} | ||
|
||
@test "No arguments prints usage instructions" { | ||
run stocks | ||
[ "$status" -eq 0 ] | ||
[ "${lines[0]}" = "Stocks" ] | ||
run "${TOOL_DIR}/${TOOL_NAME}" | ||
|
||
[[ "$status" -eq 0 ]] | ||
# if bash is less than 7 yrs old | ||
if ((${BASH_VERSINFO[0]} >= 4)); then | ||
[[ "${lines[0]}" = "${TOOL_NAME^}" ]] | ||
else | ||
# or im probably a stoneage mac | ||
[[ "$(echo "${output}" | grep -i "${TOOL_NAME}")" ]] | ||
fi | ||
} | ||
|
||
@test "Get stock info by passing in ticker" { | ||
result=$( echo $(stocks AAPL) | grep -Eo "AAPL stock info" ) | ||
[ "$result" = "AAPL stock info" ] | ||
|
||
@test "Get the tools version with -v" { | ||
run "${TOOL_DIR}/${TOOL_NAME}" -v | ||
|
||
[[ "$status" -eq 0 ]] | ||
expected='Version' | ||
[[ "${output}" =~ "${expected}" ]] | ||
} | ||
|
||
@test "Get stock info by passing in company" { | ||
result=$( echo $(stocks Apple) | grep -Eo "AAPL stock info" ) | ||
[ "$result" = "AAPL stock info" ] | ||
@test "Grabbing information on a programming language (rust)" { | ||
run "${TOOL_DIR}/${TOOL_NAME}" rust | ||
[[ "$status" -eq 0 ]] | ||
[[ "${lines[0]}" =~ 'Rust is a systems' ]] | ||
} | ||
|
||
@test "Get the tools version with -v" { | ||
run stocks -v | ||
[ "$status" -eq 0 ] | ||
result=$( echo $(stocks -v) | grep -Eo "Version") | ||
[ "$result" = "Version" ] | ||
@test "Testing unkown topic due to misspelling" { | ||
run "${TOOL_DIR}/${TOOL_NAME}" suuuper thiingsa | ||
[[ "$status" -eq 0 ]] | ||
[[ "printf '%s\n' ${lines[1]}" =~ 'Unknown' ]] | ||
} |
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,4 +1,4 @@ | ||
#!/bin/env bats | ||
#!/usr/bin/env bats | ||
|
||
@test "Testing cloudup tool" { | ||
echo cloudup | ||
|
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,4 +1,4 @@ | ||
#!/bin/env bats | ||
#!/usr/bin/env bats | ||
|
||
@test "Testing crypt tool" { | ||
echo crypt | ||
|
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,4 +1,4 @@ | ||
#!/bin/env bats | ||
#!/usr/bin/env bats | ||
|
||
@test "Testing cryptocurrency tool" { | ||
echo cryptocurrency | ||
|
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,4 +1,4 @@ | ||
#!/bin/env bats | ||
#!/usr/bin/env bats | ||
|
||
@test "Testing currency tool" { | ||
echo currency | ||
|
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,4 +1,4 @@ | ||
#!/bin/env bats | ||
#!/usr/bin/env bats | ||
|
||
@test "Testing geo tool" { | ||
echo geo | ||
|
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,4 +1,4 @@ | ||
#!/bin/env bats | ||
#!/usr/bin/env bats | ||
|
||
@test "Testing meme tool" { | ||
echo meme | ||
|
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,4 +1,4 @@ | ||
#!/bin/env bats | ||
#!/usr/bin/env bats | ||
|
||
@test "Testing movies tool" { | ||
echo movies | ||
|
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,4 +1,4 @@ | ||
#!/bin/env bats | ||
#!/usr/bin/env bats | ||
|
||
@test "Testing newton tool" { | ||
echo newton | ||
|
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,4 +1,4 @@ | ||
#!/bin/env bats | ||
#!/usr/bin/env bats | ||
|
||
@test "Testing qrify tool" { | ||
echo qrify | ||
|
Oops, something went wrong.