Skip to content

Commit

Permalink
better handles configuration variables
Browse files Browse the repository at this point in the history
  • Loading branch information
niquerio committed Oct 23, 2024
1 parent 10a1dd2 commit 1860e74
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
8 changes: 4 additions & 4 deletions bin/digifeeds/upload_to_s3.sh
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ if [[ $APP_ENV != "test" ]]; then
# shellcheck source=/dev/null
source "$CONFIG_FILE"
fi
${input_directory:?}
${processed_directory:?}
${digifeeds_bucket:?}
${send_metrics:-"true"}
if ! input_directory=${input_directory:?}; then exit 1; fi
if ! processed_directory=${processed_directory:?}; then exit 1; fi
if ! digifeeds_bucket=${digifeeds_bucket:?}; then exit 1; fi
send_metrics=${send_metrics:-"true"}

# matches .tif and .jp2 files with 8 digit file names that start with 0 OR
# checksum.md5 files
Expand Down
16 changes: 16 additions & 0 deletions bin/digifeeds/upload_to_s3_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,22 @@ teardown() {
rm -r "$SCRATCH_PATH"
}

@test "exits without input_directory" {
unset input_directory
run "${BATS_TEST_DIRNAME}/upload_to_s3.sh"
assert_failure
}
@test "exits without processed_directory" {
unset processed_directory
run "${BATS_TEST_DIRNAME}/upload_to_s3.sh"
assert_failure
}
@test "exits without digifeeds_bucket" {
unset digifeeds_bucket
run "${BATS_TEST_DIRNAME}/upload_to_s3.sh"
assert_failure
}

@test "It Works" {
shellmock new rclone
shellmock config rclone 0 1:copy regex-3:^digifeeds_bucket:
Expand Down

0 comments on commit 1860e74

Please sign in to comment.