2020-04-23 18:52:53 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
path="$1"
|
|
|
|
expectedContent="$2"
|
|
|
|
|
|
|
|
if [ "$path" == "" ]; then
|
|
|
|
echo "File path not provided"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ "$expectedContent" == "" ]; then
|
|
|
|
echo "Expected file contents not provided"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [ ! -f "$path" ]; then
|
|
|
|
echo "Expected file $path does not exist"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2021-12-14 20:50:50 +00:00
|
|
|
actualContent=$(cat "$path")
|
|
|
|
if [ "$expectedContent" == "_EMPTY_" ] && [ ! -s "$path" ]; then
|
|
|
|
exit 0
|
|
|
|
elif [ "$actualContent" != "$expectedContent" ]; then
|
2020-04-27 13:13:56 +00:00
|
|
|
echo "File contents are not correct, expected $expectedContent, received $actualContent"
|
2020-04-23 18:52:53 +00:00
|
|
|
exit 1
|
|
|
|
fi
|