diff options
author | =Corey Hulen <corey@hulen.com> | 2015-06-14 23:53:32 -0800 |
---|---|---|
committer | =Corey Hulen <corey@hulen.com> | 2015-06-14 23:53:32 -0800 |
commit | 56e74239d6b34df8f30ef046f0b0ff4ff0866a71 (patch) | |
tree | 044da29848cf0f5c8607eac34de69065171669cf /model/post_list_test.go | |
download | chat-56e74239d6b34df8f30ef046f0b0ff4ff0866a71.tar.gz chat-56e74239d6b34df8f30ef046f0b0ff4ff0866a71.tar.bz2 chat-56e74239d6b34df8f30ef046f0b0ff4ff0866a71.zip |
first commit
Diffstat (limited to 'model/post_list_test.go')
-rw-r--r-- | model/post_list_test.go | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/model/post_list_test.go b/model/post_list_test.go new file mode 100644 index 000000000..7ce36c399 --- /dev/null +++ b/model/post_list_test.go @@ -0,0 +1,36 @@ +// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +// See License.txt for license information. + +package model + +import ( + "strings" + "testing" +) + +func TestPostListJson(t *testing.T) { + + pl := PostList{} + p1 := &Post{Id: NewId(), Message: NewId()} + pl.AddPost(p1) + p2 := &Post{Id: NewId(), Message: NewId()} + pl.AddPost(p2) + + pl.AddOrder(p1.Id) + pl.AddOrder(p2.Id) + + json := pl.ToJson() + rpl := PostListFromJson(strings.NewReader(json)) + + if rpl.Posts[p1.Id].Message != p1.Message { + t.Fatal("failed to serialize") + } + + if rpl.Posts[p2.Id].Message != p2.Message { + t.Fatal("failed to serialize") + } + + if rpl.Order[1] != p2.Id { + t.Fatal("failed to serialize") + } +} |