fix(fixtures): exit the run_test function on error

This commit is contained in:
Orhun Parmaksız 2022-05-21 16:43:32 +03:00
parent 685d9607c8
commit c60090d461
No known key found for this signature in database
GPG key ID: F83424824B3E4B90
10 changed files with 20 additions and 20 deletions

View file

@ -29,9 +29,9 @@ setup() {
# preparation
}
run_test() {
run_test() ( set -e;
# assertions
}
)
teardown() {
# cleanup

View file

@ -9,7 +9,7 @@ setup() {
date +%s > unique_file2
}
run_test() {
run_test() ( set -e;
first_file_url=$(curl -s -F "file=@file" localhost:8000)
test "$duplicate_content" = "$(cat upload/file.txt)"
@ -22,7 +22,7 @@ run_test() {
first_file_url=$(curl -s -F "file=@unique_file1" localhost:8000)
second_file_url=$(curl -s -F "file=@unique_file2" localhost:8000)
test "$first_file_url" != "$second_file_url"
}
)
teardown() {
rm file unique_file1 unique_file2

View file

@ -6,14 +6,14 @@ setup() {
echo "$content" > file
}
run_test() {
run_test() ( set -e;
file_url=$(curl -s -F "file=@file" -H "expire:1s" localhost:8000)
test "$content" = "$(cat upload/file.txt.*)"
sleep 2s
result="$(curl -s $file_url)"
test "file is not found or expired :(" = "$result"
}
)
teardown() {
rm file

View file

@ -6,12 +6,12 @@ setup() {
echo "$content" > file
}
run_test() {
run_test() ( set -e;
file_url=$(curl -s -F "file=@file" localhost:8000)
test "$file_url" = "http://localhost:8000/file.txt"
test "$content" = "$(cat upload/file.txt)"
test "$content" = "$(curl -s $file_url)"
}
)
teardown() {
rm file

View file

@ -6,14 +6,14 @@ setup() {
echo "$content" > file
}
run_test() {
run_test() ( set -e;
file_url=$(curl -s -F "oneshot=@file" localhost:8000)
test "$content" = $(curl -s "$file_url")
test "$content" = "$(cat upload/oneshot/file.txt.*)"
result="$(curl -s $file_url)"
test "file is not found or expired :(" = "$result"
}
)
teardown() {
rm file

View file

@ -6,7 +6,7 @@ setup() {
echo "$content" > file
}
run_test() {
run_test() ( set -e;
result=$(curl -s --path-as-is localhost:8000/.)
test "file is not found or expired :(" = "$result"
@ -15,7 +15,7 @@ run_test() {
result=$(curl -s -X POST -F "file=@file;filename=../." localhost:8000)
test "$content" = "$(cat upload/file.txt)"
}
)
teardown() {
rm file

View file

@ -6,12 +6,12 @@ setup() {
:;
}
run_test() {
run_test() ( set -e;
file_url=$(curl -s -F "remote=$url" localhost:8000)
curl -s "$file_url" -o uploaded_file > /dev/null
curl -s "$url" -o remote_file > /dev/null
test "$(sha256sum uploaded_file | awk '{print $1}')" = "$(sha256sum remote_file | awk '{print $1}')"
}
)
teardown() {
rm uploaded_file remote_file

View file

@ -7,7 +7,7 @@ setup() {
echo "$content" > file
}
run_test() {
run_test() ( set -e;
result=$(curl -s -F "file=@file" localhost:8000)
test "unauthorized" = "$result"
@ -15,7 +15,7 @@ run_test() {
test "unauthorized" != "$result"
test "$content" = "$(cat upload/file.txt)"
test "$content" = "$(curl -s $result)"
}
)
teardown() {
rm file

View file

@ -7,7 +7,7 @@ setup() {
truncate -s 11KB bigfile
}
run_test() {
run_test() ( set -e;
result=$(curl -s -F "file=@emptyfile" localhost:8000)
test "invalid file size" = "$result"
@ -19,7 +19,7 @@ run_test() {
result=$(curl -s -F "file=@smallfile" localhost:8000)
test "upload limit exceeded" != "$result"
}
)
teardown() {
rm emptyfile smallfile normalfile bigfile

View file

@ -6,13 +6,13 @@ setup() {
:;
}
run_test() {
run_test() ( set -e;
curl -s -F "url=$url" localhost:8000 > /dev/null
test "$url" = "$(cat upload/url/url)"
result=$(curl -s -F "url=invalidurl" localhost:8000)
test "relative URL without a base" = "$result"
}
)
teardown() {
rm -r upload