github.com/wgh-/mattermost-server@v4.8.0-rc2+incompatible/model/cluster_message_test.go (about) 1 // Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved. 2 // See License.txt for license information. 3 4 package model 5 6 import ( 7 "strings" 8 "testing" 9 ) 10 11 func TestClusterMessage(t *testing.T) { 12 m := ClusterMessage{ 13 Event: CLUSTER_EVENT_PUBLISH, 14 SendType: CLUSTER_SEND_BEST_EFFORT, 15 Data: "hello", 16 } 17 json := m.ToJson() 18 result := ClusterMessageFromJson(strings.NewReader(json)) 19 20 if result.Data != "hello" { 21 t.Fatal() 22 } 23 24 badresult := ClusterMessageFromJson(strings.NewReader("junk")) 25 if badresult != nil { 26 t.Fatal("should not have parsed") 27 } 28 }