]>
Commit | Line | Data |
---|---|---|
cc9bd370 SW |
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() | |
fa5e7c1b | 11 | store.Add <- &Message{at, say} |
cc9bd370 | 12 | messages_from_store := make(chan []Message, 1) |
fa5e7c1b | 13 | store.Get <- &StoreRequest{zero_time, messages_from_store} |
cc9bd370 SW |
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 | } | |
c282d878 SW |
24 | close(store.Get) |
25 | close(store.Add) | |
cc9bd370 | 26 | } |