Skip to content

Commit

Permalink
Update tests to allow symlink
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolemah99 committed Jul 31, 2024
1 parent a3552b6 commit 3666066
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion cli_meter/test/test_helper/common.bash
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ _common_setup() {
EVENT_ID="1234"
METER_IP="123.123.123"
DATA_TYPE="events"
ZIP_FILENAME="$LOCATION-$METER_TYPE-$METER_ID-YYYYMM-$EVENT_ID.zip"
SYMLINK_NAME="$LOCATION-$METER_TYPE-$METER_ID-YYYYMM-$EVENT_ID"
ZIP_FILENAME="${SYMLINK_NAME}.zip"
}

_common_teardown() {
Expand Down
8 changes: 4 additions & 4 deletions cli_meter/test/test_scripts.bats
Original file line number Diff line number Diff line change
Expand Up @@ -45,20 +45,20 @@ teardown() {

@test "zip_event.sh execution test" {
mkdir -p "$TMP_DIR/$EVENT_ID"
run ./zip_event.sh "$TMP_DIR" "$TMP_DIR" "$EVENT_ID" "$ZIP_FILENAME"
run ./zip_event.sh "$TMP_DIR" "$TMP_DIR" "$EVENT_ID" "$SYMLINK_NAME"
assert_success
assert_output --partial "Zipped files for event: $EVENT_ID"
assert_output --partial "Successfully zipped symlink: $SYMLINK_NAME to $TMP_DIR/$ZIP_FILENAME for event: $EVENT_ID"
assert [ -f "$TMP_DIR/$ZIP_FILENAME" ]
assert [ -d "$TMP_DIR/$EVENT_ID" ]
}

@test "zip_event.sh test 0 arguments" {
run ./zip_event.sh
assert_failure $(($STREAMS_INVALID_ARGS % 256))
assert_output --partial "Usage: zip_event.sh <source_dir> <dest_dir> <event_id> <zip_filename>"
assert_output --partial "Usage: zip_event.sh <source_dir> <dest_dir> <event_id> <symlink_name>"
}

@test "zip_event.sh test invalid event_id" {
run ./zip_event.sh "$TMP_DIR" "$TMP_DIR" "not_a_directory" "$ZIP_FILENAME"
run ./zip_event.sh "$TMP_DIR" "$TMP_DIR" "not_a_directory" "$SYMLINK_NAME"
assert_failure $(($STREAMS_DIR_NOT_FOUND % 256))
}

0 comments on commit 3666066

Please sign in to comment.