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
2012-07-18 16:08:51 +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
2012-07-18 16:08:51 +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
2012-07-18 16:08:51 +00:00
let BEFORE=`date +%s`000-10000 # 10 seconds ago
let AFTER=`date +%s`000+10000 # 10 seconds from now
curl --silent http://${HOST}/RoomA?since=${BEFORE}&until=${AFTER} \
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
2012-07-18 16:08:51 +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"
}'