more tests, including a small sse count

This commit is contained in:
Simon Cruanes 2021-12-11 10:02:32 -05:00
parent c8982c8836
commit ed4c731523
No known key found for this signature in database
GPG key ID: 4AC01D0849AA62B6
4 changed files with 53 additions and 0 deletions

20
tests/dune Normal file
View file

@ -0,0 +1,20 @@
(rule
(targets echo1.out)
(deps (:bin ../examples/echo.exe))
(locks /port)
(action (with-stdout-to %{targets} (run ./echo1.sh %{bin}))))
(rule
(alias runtest)
(action (diff echo1.expect echo1.out)))
(rule
(targets sse_count.out)
(deps (:bin ../examples/sse_server.exe))
(locks /port)
(action (with-stdout-to %{targets} (run ./sse_count.sh %{bin}))))
(rule
(alias runtest)
(action (diff sse_count.expect sse_count.out)))

23
tests/sse_count.expect Normal file
View file

@ -0,0 +1,23 @@
listening on http://localhost:8083/
data: 0
data: 1
data: 2
data: 3
data: 4
data: 5
data: 6
data: 7
data: 8
data: 9
data: 10

9
tests/sse_count.sh Executable file
View file

@ -0,0 +1,9 @@
#!/usr/bin/env sh
SSE_SERVER=$1
"$SSE_SERVER" -p 8083 &
sleep 0.1
curl -N 'http://localhost:8083/count/10' -H user-agent:test
kill %1

View file

@ -15,6 +15,7 @@ depends: [
"ocaml" { >= "4.04.0" }
"odoc" {with-doc}
"qtest" { >= "2.9" & with-test}
"conf-curl" {with-test}
"qcheck" {with-test & >= "0.9" }
"ounit2" {with-test}
"ptime" {with-test}