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 /store/redis_test.go | |
download | chat-56e74239d6b34df8f30ef046f0b0ff4ff0866a71.tar.gz chat-56e74239d6b34df8f30ef046f0b0ff4ff0866a71.tar.bz2 chat-56e74239d6b34df8f30ef046f0b0ff4ff0866a71.zip |
first commit
Diffstat (limited to 'store/redis_test.go')
-rw-r--r-- | store/redis_test.go | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/store/redis_test.go b/store/redis_test.go new file mode 100644 index 000000000..11bd9ca6a --- /dev/null +++ b/store/redis_test.go @@ -0,0 +1,59 @@ +// Copyright (c) 2015 Spinpunch, Inc. All Rights Reserved. +// See License.txt for license information. + +package store + +import ( + "fmt" + "github.com/mattermost/platform/model" + "github.com/mattermost/platform/utils" + "testing" +) + +func TestRedis(t *testing.T) { + utils.LoadConfig("config.json") + + c := RedisClient() + + if c == nil { + t.Fatal("should have a valid redis connection") + } + + pubsub := c.PubSub() + defer pubsub.Close() + + m := model.NewMessage(model.NewId(), model.NewId(), model.NewId(), model.ACTION_TYPING) + m.Add("RootId", model.NewId()) + + err := pubsub.Subscribe(m.TeamId) + if err != nil { + t.Fatal(err) + } + + // should be the subscribe success message + // lets gobble that up + if _, err := pubsub.Receive(); err != nil { + t.Fatal(err) + } + + PublishAndForget(m) + + fmt.Println("here1") + + if msg, err := pubsub.Receive(); err != nil { + t.Fatal(err) + } else { + + rmsg := GetMessageFromPayload(msg) + + if m.TeamId != rmsg.TeamId { + t.Fatal("Ids do not match") + } + + if m.Props["RootId"] != rmsg.Props["RootId"] { + t.Fatal("Ids do not match") + } + } + + RedisClose() +} |