summaryrefslogtreecommitdiffstats
path: root/model/status_test.go
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2018-06-21 13:42:20 -0400
committerChristopher Speller <crspeller@gmail.com>2018-06-21 10:42:20 -0700
commit46f969e5ddbe4404dbc82dbe78ab2fa101d9922e (patch)
treef526b349e193f085b2641548ebf97f3c448ac5a6 /model/status_test.go
parentd36ad6cb54b636fd315794be6aa9fd76c995e264 (diff)
downloadchat-46f969e5ddbe4404dbc82dbe78ab2fa101d9922e.tar.gz
chat-46f969e5ddbe4404dbc82dbe78ab2fa101d9922e.tar.bz2
chat-46f969e5ddbe4404dbc82dbe78ab2fa101d9922e.zip
MM-10425 Include active_channel in cluster update user status messages (#8967)
* Include active_channel in cluster update user status messages * Update to use new ToJson method * Update tests
Diffstat (limited to 'model/status_test.go')
-rw-r--r--model/status_test.go29
1 files changed, 18 insertions, 11 deletions
diff --git a/model/status_test.go b/model/status_test.go
index 4b15fb32e..d2e519006 100644
--- a/model/status_test.go
+++ b/model/status_test.go
@@ -7,10 +7,12 @@ import (
"encoding/json"
"strings"
"testing"
+
+ "github.com/stretchr/testify/assert"
)
func TestStatus(t *testing.T) {
- status := Status{NewId(), STATUS_ONLINE, true, 0, ""}
+ status := Status{NewId(), STATUS_ONLINE, true, 0, "123"}
json := status.ToJson()
status2 := StatusFromJson(strings.NewReader(json))
@@ -29,10 +31,17 @@ func TestStatus(t *testing.T) {
if status.Manual != status2.Manual {
t.Fatal("Manual should have matched")
}
+
+ assert.Equal(t, "", status2.ActiveChannel)
+
+ json = status.ToClusterJson()
+ status2 = StatusFromJson(strings.NewReader(json))
+
+ assert.Equal(t, status.ActiveChannel, status2.ActiveChannel)
}
func TestStatusListToJson(t *testing.T) {
- statuses := []*Status{{NewId(), STATUS_ONLINE, true, 0, ""}, {NewId(), STATUS_OFFLINE, true, 0, ""}}
+ statuses := []*Status{{NewId(), STATUS_ONLINE, true, 0, "123"}, {NewId(), STATUS_OFFLINE, true, 0, ""}}
jsonStatuses := StatusListToJson(statuses)
var dat []map[string]interface{}
@@ -40,15 +49,13 @@ func TestStatusListToJson(t *testing.T) {
panic(err)
}
- if len(dat) != 2 {
- t.Fatal("Status array should contain 2 elements")
- }
- if statuses[0].UserId != dat[0]["user_id"] {
- t.Fatal("UserId should be equal")
- }
- if statuses[1].UserId != dat[1]["user_id"] {
- t.Fatal("UserId should be equal")
- }
+ assert.Equal(t, len(dat), 2)
+
+ _, ok := dat[0]["active_channel"]
+ assert.False(t, ok)
+ assert.Equal(t, statuses[0].ActiveChannel, "123")
+ assert.Equal(t, statuses[0].UserId, dat[0]["user_id"])
+ assert.Equal(t, statuses[1].UserId, dat[1]["user_id"])
}
func TestStatusListFromJson(t *testing.T) {