]> git.scottworley.com Git - reliable-chat/commitdiff
Add a test
authorScott Worley <sworley@chkno.net>
Sat, 28 Jul 2012 17:45:00 +0000 (10:45 -0700)
committerScott Worley <sworley@chkno.net>
Sat, 28 Jul 2012 17:45:00 +0000 (10:45 -0700)
server/server_test.go [new file with mode: 0644]

diff --git a/server/server_test.go b/server/server_test.go
new file mode 100644 (file)
index 0000000..0afb384
--- /dev/null
@@ -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()
+       }
+}