diff --git a/scripts/test-init.sh b/scripts/test-init.sh index 93c33ad1..c0fac963 100755 --- a/scripts/test-init.sh +++ b/scripts/test-init.sh @@ -7,14 +7,29 @@ url="https://kanaries-app.s3.ap-northeast-1.amazonaws.com/public-datasets/bike_s dir="./tests" # Create the directory if it doesn't exist -mkdir -p "$dir" +mkdir -p "$dir" || { + echo "Error: could not create directory '$dir'" >&2 + exit 1 +} # Download the file using curl if command -v curl >/dev/null; then - curl "$url" -o "$dir/bike_sharing_dc.csv" + curl -f "$url" -o "$dir/bike_sharing_dc.csv" || { + echo "Error: could not download file from '$url'" >&2 + exit 1 + } elif command -v wget >/dev/null; then - wget "$url" -O "$dir/bike_sharing_dc.csv" + wget -q --show-progress "$url" -O "$dir/bike_sharing_dc.csv" || { + echo "Error: could not download file from '$url'" >&2 + exit 1 + } else echo "Error: could not find curl or wget to download the file" >&2 exit 1 -fi \ No newline at end of file +fi + +# Check if the file was downloaded successfully +if [ ! -f "$dir/bike_sharing_dc.csv" ]; then + echo "Error: file '$dir/bike_sharing_dc.csv' was not downloaded successfully" >&2 + exit 1 +fi