fizzbuzz/json-chat-nodejs/tests.sh

58 lines
1.4 KiB
Bash
Raw Normal View History

2011-08-15 20:46:18 +00:00
#!/bin/bash
HOST=localhost:5080
# immediatley adds a message to RoomA
2011-08-29 19:43:59 +00:00
curl --silent "http://${HOST}/RoomA" \
2011-08-15 20:46:18 +00:00
-X POST \
-H 'Content-Type: application/json' \
-d '{
"name": "AJ"
, "message": "Hello World"
}'
# output should look something like
# { "error": false, "errors": [], "timestamp": 1234567890, "status": "ok"}
# immediatley adds a message to RoomB
2011-08-29 19:43:59 +00:00
curl --silent "http://${HOST}/RoomB" \
2011-08-15 20:46:18 +00:00
-X POST \
-H 'Content-Type: application/json' \
-d '{
"name": "AJ"
, "message": "Hello Anti-World"
}'
# waits 10 seconds before responding with the latest messages
# should get the message
let WHEN=`date +%s`000-10000 # 10 seconds ago
let THEN=`date +%s`000+10000 # 10 seconds from now
2011-08-29 19:43:59 +00:00
curl --silent "http://${HOST}/RoomA?since=${WHEN}&until=${THEN}" \
2011-08-15 20:46:18 +00:00
-X POST \
-H 'Content-Type: application/json' \
-d '{
"name": "AJ"
, "message": "Hello Anti-World"
}' \
&
# output should look something like
# [
# { "timestamp": 1234567890, "name": "AJ", "message": "blah..."}
# , { "timestamp": 1234567890, "name": "Eric", "message": "blah..."}
# ]
# this should post to RoomA and be seen in the request above
sleep 5
2011-08-29 19:43:59 +00:00
curl --silent "http://${HOST}/RoomA" \
2011-08-15 20:46:18 +00:00
-X POST \
-H 'Content-Type: application/json' \
-d '{
"name": "Eric"
, "message": "Hello Back Atcha"
}'