github.com/masterhung0112/hk_server/v5@v5.0.0-20220302090640-ec71aef15e1c/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 "github.com/stretchr/testify/assert" 11 ) 12 13 func TestClusterInfoJson(t *testing.T) { 14 cluster := ClusterInfo{IpAddress: NewId(), Hostname: NewId()} 15 json := cluster.ToJson() 16 result := ClusterInfoFromJson(strings.NewReader(json)) 17 18 assert.Equal(t, cluster.IpAddress, result.IpAddress, "Ids do not match") 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 assert.Equal(t, clusterInfos[0].IpAddress, result[0].IpAddress, "Ids do not match") 29 }