7 func TestMessageInsertAndRetreive(t *testing.T) {
8 say := "'Ello, Mister Polly Parrot!"
10 var zero_time time.Time
11 store := start_store()
12 store.Add <- &Message{at, say}
13 messages_from_store := make(chan []Message, 1)
14 store.Get <- &StoreRequest{zero_time, messages_from_store}
15 messages := <-messages_from_store
16 if len(messages) != 1 {
19 if messages[0].Time != at {
22 if messages[0].Text != say {
29 func TestFetchBlocksUntilSpeak(t *testing.T) {
30 start_fetch_wait_count := fetch_wait_count.String()
31 say := "I've got a lovely fresh cuttle fish for you"
33 var zero_time time.Time
34 store := start_store()
35 messages_from_store := make(chan []Message, 1)
36 store.Get <- &StoreRequest{zero_time, messages_from_store}
37 for start_fetch_wait_count == fetch_wait_count.String() {
40 store.Add <- &Message{at, say}
41 messages := <-messages_from_store
42 if len(messages) != 1 {
45 if messages[0].Time != at {
48 if messages[0].Text != say {
55 func TestMultipleListeners(t *testing.T) {
56 say := "This is your nine o'clock alarm call!"
58 var zero_time time.Time
59 store := start_store()
60 const num_clients = 13
61 var messages_from_store [num_clients]chan []Message
62 for i := 0; i < num_clients; i++ {
63 messages_from_store[i] = make(chan []Message, 1)
64 store.Get <- &StoreRequest{zero_time, messages_from_store[i]}
66 store.Add <- &Message{at, say}
67 for i := 0; i < num_clients; i++ {
68 messages := <-messages_from_store[i]
69 if len(messages) != 1 {
72 if messages[0].Time != at {
75 if messages[0].Text != say {