github.com/rajatvaryani/mattermost-server@v5.11.1+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 "github.com/stretchr/testify/require" 11 ) 12 13 func TestClusterMessage(t *testing.T) { 14 m := ClusterMessage{ 15 Event: CLUSTER_EVENT_PUBLISH, 16 SendType: CLUSTER_SEND_BEST_EFFORT, 17 Data: "hello", 18 } 19 json := m.ToJson() 20 result := ClusterMessageFromJson(strings.NewReader(json)) 21 22 require.Equal(t, "hello", result.Data) 23 24 badresult := ClusterMessageFromJson(strings.NewReader("junk")) 25 if badresult != nil { 26 t.Fatal("should not have parsed") 27 } 28 }