From deec5d4c2987e7b6b67e329066db13cf1bcdf25a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Orhun=20Parmaks=C4=B1z?= Date: Sat, 21 May 2022 19:31:43 +0300 Subject: [PATCH] test(fixtures): add fixture test for random URL --- fixtures/test-random-url/config.toml | 9 +++++++++ fixtures/test-random-url/test.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 fixtures/test-random-url/config.toml create mode 100755 fixtures/test-random-url/test.sh diff --git a/fixtures/test-random-url/config.toml b/fixtures/test-random-url/config.toml new file mode 100644 index 0000000..82c0ef7 --- /dev/null +++ b/fixtures/test-random-url/config.toml @@ -0,0 +1,9 @@ +[server] +address="127.0.0.1:8000" +max_content_length="10MB" +upload_path="./upload" + +[paste] +random_url = { enabled = true, type = "alphanumeric", length = "8" } +default_extension = "txt" +duplicate_files = true diff --git a/fixtures/test-random-url/test.sh b/fixtures/test-random-url/test.sh new file mode 100755 index 0000000..155dea6 --- /dev/null +++ b/fixtures/test-random-url/test.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +content="test data" + +setup() { + echo "$content" > file +} + +run_test() { + first_file_url=$(curl -s -F "file=@file" localhost:8000) + test "$first_file_url" != "http://localhost:8000/file.txt" + test "$content" = "$(curl -s $first_file_url)" + + second_file_url=$(curl -s -F "file=@file" localhost:8000) + test "$first_file_url" != "http://localhost:8000/file.txt" + test "$content" = "$(curl -s $first_file_url)" + + test "$first_file_url" != "$second_file_url" + + test "$(cat upload/${first_file_url/http:\/\/localhost:8000\//})" \ + = "$(cat upload/${second_file_url/http:\/\/localhost:8000\//})" +} + +teardown() { + rm file + rm -r upload +}