]> git.scottworley.com Git - reliable-chat/blob - server/server_test.go
Shut down the message store after each test
[reliable-chat] / server / server_test.go
1 package main
2
3 import "testing"
4 import "time"
5
6 func TestMessageInsertAndRetreive(t *testing.T) {
7 say := ""
8 at := time.Now()
9 var zero_time time.Time
10 store := start_store()
11 store.Add <- &Message{at, say}
12 messages_from_store := make(chan []Message, 1)
13 store.Get <- &StoreRequest{zero_time, messages_from_store}
14 messages := <-messages_from_store
15 if len(messages) != 1 {
16 t.Fail()
17 }
18 if messages[0].Time != at {
19 t.Fail()
20 }
21 if messages[0].Text != say {
22 t.Fail()
23 }
24 close(store.Get)
25 close(store.Add)
26 }