Skip to content

Commit

Permalink
Expanded integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Minituff committed Oct 24, 2023
1 parent 377b259 commit 95fe078
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 7 deletions.
60 changes: 53 additions & 7 deletions pkg/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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!"
echo "All tests passed!"
1 change: 1 addition & 0 deletions tests/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 95fe078

Please sign in to comment.