From: Scott Worley Date: Sat, 28 Jul 2012 17:45:00 +0000 (-0700) Subject: Add a test X-Git-Url: http://git.scottworley.com/reliable-chat/commitdiff_plain/cc9bd37043c30f835fb38ac022ca6e65e5724925?ds=inline;hp=--cc Add a test --- cc9bd37043c30f835fb38ac022ca6e65e5724925 diff --git a/server/server_test.go b/server/server_test.go new file mode 100644 index 0000000..0afb384 --- /dev/null +++ b/server/server_test.go @@ -0,0 +1,24 @@ +package main + +import "testing" +import "time" + +func TestMessageInsertAndRetreive(t *testing.T) { + say := "" + at := time.Now() + var zero_time time.Time + store := start_store() + store.Add <- Message{at, say} + messages_from_store := make(chan []Message, 1) + store.Get <- StoreRequest{zero_time, messages_from_store} + messages := <-messages_from_store + if len(messages) != 1 { + t.Fail() + } + if messages[0].Time != at { + t.Fail() + } + if messages[0].Text != say { + t.Fail() + } +}