github.com/ashishbhate/mattermost-server@v5.11.1+incompatible/model/cluster_info_test.go (about)

     1  // Copyright (c) 2015-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 TestClusterInfoJson(t *testing.T) {
    12  	cluster := ClusterInfo{IpAddress: NewId(), Hostname: NewId()}
    13  	json := cluster.ToJson()
    14  	result := ClusterInfoFromJson(strings.NewReader(json))
    15  
    16  	if cluster.IpAddress != result.IpAddress {
    17  		t.Fatal("Ids do not match")
    18  	}
    19  }
    20  
    21  func TestClusterInfosJson(t *testing.T) {
    22  	cluster := ClusterInfo{IpAddress: NewId(), Hostname: NewId()}
    23  	clusterInfos := make([]*ClusterInfo, 1)
    24  	clusterInfos[0] = &cluster
    25  	json := ClusterInfosToJson(clusterInfos)
    26  	result := ClusterInfosFromJson(strings.NewReader(json))
    27  
    28  	if clusterInfos[0].IpAddress != result[0].IpAddress {
    29  		t.Fatal("Ids do not match")
    30  	}
    31  }