summaryrefslogtreecommitdiffstats
path: root/model/cluster_message_test.go
blob: e9225a5c5061bf92b905e24f9d38f922775c82b1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.

package model

import (
	"strings"
	"testing"

	"github.com/stretchr/testify/require"
)

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))

	require.Equal(t, "hello", result.Data)

	badresult := ClusterMessageFromJson(strings.NewReader("junk"))
	if badresult != nil {
		t.Fatal("should not have parsed")
	}
}