add an upload test

This commit is contained in:
Simon Cruanes 2021-12-11 10:14:07 -05:00
parent ed4c731523
commit 69c16b0a5d
No known key found for this signature in database
GPG key ID: 4AC01D0849AA62B6
5 changed files with 31 additions and 1 deletions

View file

@ -5,9 +5,12 @@ all: build test
build: build:
@dune build @install @dune build @install
test: test: tests/foo_50
@dune runtest --no-buffer --force @dune runtest --no-buffer --force
tests/foo_50:
dd if=/dev/zero of=$@ bs=1M count=50
clean: clean:
@dune clean @dune clean

1
tests/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
foo_50

View file

@ -18,3 +18,14 @@
(rule (rule
(alias runtest) (alias runtest)
(action (diff sse_count.expect sse_count.out))) (action (diff sse_count.expect sse_count.out)))
(rule
(targets upload-out)
(deps (:bin ../src/bin/http_of_dir.exe) foo_50)
(locks /port)
(action (with-stdout-to %{targets}
(run ./upload_chunked.sh %{bin}))))
(rule
(alias runtest)
(action (diff upload-out.expect upload-out)))

2
tests/upload-out.expect Normal file
View file

@ -0,0 +1,2 @@
serve directory . on http://127.0.0.1:8083
upload successful 0 0 52428800 data

13
tests/upload_chunked.sh Executable file
View file

@ -0,0 +1,13 @@
#!/usr/bin/env sh
rm data
SERVER=$1
"$SERVER" . -p 8083 --upload --max-upload 100000000000 &
sleep 0.1
cat foo_50 | curl -N -X PUT http://localhost:8083/data --data-binary @- -H 'Transfer-Encoding: chunked'
kill %1
wc data