Skip to content

Commit 6032dce

Browse files
committed
test: add download test case
1 parent e57df4b commit 6032dce

File tree

3 files changed

+20
-3
lines changed

3 files changed

+20
-3
lines changed

test/case/009.download.bash

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
source "$root"/lib.bash
4+
5+
"$ghfs" -l 3003 -r "$fs"/vhost1 &
6+
sleep 0.05 # wait server ready
7+
8+
(curl_get_header http://127.0.0.1:3003/file1.txt | grep -q -i -F 'content-disposition') &&
9+
fail "Content-Disposition header should not exists"
10+
11+
(curl_get_header http://127.0.0.1:3003/file1.txt?download | grep -q -i -F 'content-disposition') ||
12+
fail "Content-Disposition header is not exists"
13+
14+
kill %1

test/lib.bash

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ curl_head_status() {
2020

2121
curl_get_status() {
2222
url="$1"
23-
opts="$2"
2423
curl -s -k -i "$url" | head -n 1 | cut -d ' ' -f 2
2524
}
2625

26+
curl_get_header() {
27+
url="$1"
28+
curl -s -k -i "$url" | sed -e '/^$/q'
29+
}
30+
2731
curl_get_body() {
2832
url="$1"
29-
opts="$2"
3033
curl -s -k "$url"
3134
}
3235

test/main.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
cd $(dirname $0)
44

5-
for cmd in realpath curl grep; do
5+
for cmd in realpath curl grep sed; do
66
type "$cmd" &> /dev/null
77
if [ $? -ne 0 ]; then
88
echo "command '$cmd' not found" >&2

0 commit comments

Comments
 (0)