mirror of
https://github.com/amigan/rustypaste-pretty.git
synced 2024-11-21 11:59:48 -05:00
test(fixtures): add fixture test for auto deletion
This commit is contained in:
parent
a6a8261a73
commit
d262a3d297
2 changed files with 34 additions and 0 deletions
10
fixtures/test-server-auto-deletion/config.toml
Normal file
10
fixtures/test-server-auto-deletion/config.toml
Normal file
|
@ -0,0 +1,10 @@
|
|||
[server]
|
||||
address="127.0.0.1:8000"
|
||||
max_content_length="10MB"
|
||||
upload_path="./upload"
|
||||
|
||||
[paste]
|
||||
random_url = { enabled = true, type = "petname", words = 2, separator = "-" }
|
||||
default_extension = "txt"
|
||||
duplicate_files = true
|
||||
delete_expired_files = { enabled = true, interval = "2s" }
|
24
fixtures/test-server-auto-deletion/test.sh
Executable file
24
fixtures/test-server-auto-deletion/test.sh
Executable file
|
@ -0,0 +1,24 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
content="test content"
|
||||
|
||||
setup() {
|
||||
echo "$content" > file
|
||||
}
|
||||
|
||||
run_test() {
|
||||
first_file_url=$(curl -s -F "file=@file" -H "expire:1s" localhost:8000)
|
||||
second_file_url=$(curl -s -F "file=@file" -H "expire:4s" localhost:8000)
|
||||
test "$content" = "$(curl -s $first_file_url)"
|
||||
test "$content" = "$(curl -s $second_file_url)"
|
||||
sleep 3s
|
||||
test "file is not found or expired :(" = "$(curl -s $first_file_url)"
|
||||
test "$content" = "$(curl -s $second_file_url)"
|
||||
sleep 1s
|
||||
test "file is not found or expired :(" = "$(curl -s $second_file_url)"
|
||||
}
|
||||
|
||||
teardown() {
|
||||
rm file
|
||||
rm -r upload
|
||||
}
|
Loading…
Reference in a new issue