diff --git a/pkg/test.sh b/pkg/test.sh index 5b42733e..099051ef 100755 --- a/pkg/test.sh +++ b/pkg/test.sh @@ -22,13 +22,11 @@ test_cron() { fi } - - test_bash() { EXPECTED_OUTPUT="/bin/bash" ACTUAL_OUTPUT=$(which bash) - # Compare the actual output to the expected output + # Compare the actual output to the expected output if [ "$ACTUAL_OUTPUT" == "$EXPECTED_OUTPUT" ]; then echo "Test Passed: Output matches expected output." else @@ -37,13 +35,21 @@ test_bash() { echo "Got: $ACTUAL_OUTPUT" exit 1 fi + + # Use 'bash --version' to check if it returns something + if [[ $(bash --version) ]]; then + echo "Test Passed: 'bash --version' returns a value." + else + echo "Test Failed: 'bash --version' did not return a value." + exit 1 + fi } test_rsync() { EXPECTED_OUTPUT="/usr/bin/rsync" ACTUAL_OUTPUT=$(which rsync) - # Compare the actual output to the expected output + # Compare the actual output to the expected output if [ "$ACTUAL_OUTPUT" == "$EXPECTED_OUTPUT" ]; then echo "Test Passed: Rsync is installed" else @@ -52,13 +58,22 @@ test_rsync() { echo "Got: $ACTUAL_OUTPUT" exit 1 fi + + + # Use 'rsync --version' to check if it returns something + if [[ $(rsync --version) ]]; then + echo "Test Passed: 'rsync --version' returns a value." + else + echo "Test Failed: 'rsync --version' did not return a value." + exit 1 + fi } -test_jq(){ +test_jq() { EXPECTED_OUTPUT="/usr/bin/jq" ACTUAL_OUTPUT=$(which jq) - # Compare the actual output to the expected output + # Compare the actual output to the expected output if [ "$ACTUAL_OUTPUT" == "$EXPECTED_OUTPUT" ]; then echo "Test Passed: QJ is installed" else @@ -67,10 +82,41 @@ test_jq(){ echo "Got: $ACTUAL_OUTPUT" exit 1 fi + + # Use 'jq --help' to check if it returns something + if [[ $(jq --help) ]]; then + echo "Test Passed: 'jq --help' returns a value." + else + echo "Test Failed: 'jq --help' did not return a value." + exit 1 + fi } +test_tz(){ + EXPECTED_OUTPUT="America/Los_Angeles" + ACTUAL_OUTPUT=$(echo $TZ) + + # Compare the actual output to the expected output + if [ "$ACTUAL_OUTPUT" == "$EXPECTED_OUTPUT" ]; then + echo "Test Passed: Output matches expected output." + else + echo "Test Failed: Output does not match expected output." + echo "Expected: $EXPECTED_OUTPUT" + echo "Got: $ACTUAL_OUTPUT" + exit 1 + fi + + # Use 'date | grep PDT' to check if it returns something + if [[ $(date | grep PDT) ]]; then + echo "Test Passed: 'date | grep PDT' returns a value." + else + echo "Test Failed: 'date | grep PDT' did not return a value." + exit 1 + fi +} test_cron +test_tz test_bash test_rsync test_jq -echo "All tests passed!" \ No newline at end of file +echo "All tests passed!" diff --git a/tests/docker-compose.yml b/tests/docker-compose.yml index 2a0f3cbb..960fb85f 100644 --- a/tests/docker-compose.yml +++ b/tests/docker-compose.yml @@ -9,6 +9,7 @@ services: - ./destination:/app/destination entrypoint: /bin/bash app/test.sh environment: + - TZ=America/Los_Angeles - BACKUP_ON_START=true - EXIT_AFTER_INIT=true - LOG_LEVEL=DEBUG