]> git.scottworley.com Git - reliable-chat/blame - server/server_test.go
Add a test
[reliable-chat] / server / server_test.go
CommitLineData
cc9bd370
SW
1package main
2
3import "testing"
4import "time"
5
6func 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}