2017-06-19 08:44:04 -07:00
|
|
|
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
|
|
|
|
// See License.txt for license information.
|
|
|
|
|
|
|
|
|
|
package model
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"strings"
|
|
|
|
|
"testing"
|
2018-08-09 05:26:38 -04:00
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
2017-06-19 08:44:04 -07:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func TestClusterMessage(t *testing.T) {
|
|
|
|
|
m := ClusterMessage{
|
|
|
|
|
Event: CLUSTER_EVENT_PUBLISH,
|
|
|
|
|
SendType: CLUSTER_SEND_BEST_EFFORT,
|
|
|
|
|
Data: "hello",
|
|
|
|
|
}
|
|
|
|
|
json := m.ToJson()
|
|
|
|
|
result := ClusterMessageFromJson(strings.NewReader(json))
|
|
|
|
|
|
2018-08-09 05:26:38 -04:00
|
|
|
require.Equal(t, "hello", result.Data)
|
2017-06-19 08:44:04 -07:00
|
|
|
|
|
|
|
|
badresult := ClusterMessageFromJson(strings.NewReader("junk"))
|
2019-10-08 08:02:50 +01:00
|
|
|
|
|
|
|
|
require.Nil(t, badresult, "should not have parsed")
|
2017-06-19 08:44:04 -07:00
|
|
|
}
|