mirror of
https://github.com/amigan/rustypaste-pretty.git
synced 2024-11-21 11:59:48 -05:00
test(fixtures): add fixture test for random URL
This commit is contained in:
parent
a98f0ae22e
commit
deec5d4c29
2 changed files with 36 additions and 0 deletions
9
fixtures/test-random-url/config.toml
Normal file
9
fixtures/test-random-url/config.toml
Normal file
|
@ -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
|
27
fixtures/test-random-url/test.sh
Executable file
27
fixtures/test-random-url/test.sh
Executable file
|
@ -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
|
||||
}
|
Loading…
Reference in a new issue