1// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. 2// See LICENSE.txt for license information. 3 4package model 5 6import ( 7 "testing" 8 9 "github.com/stretchr/testify/assert" 10) 11 12func TestClusterDiscovery(t *testing.T) { 13 o := ClusterDiscovery{ 14 Type: "test_type", 15 ClusterName: "cluster_name", 16 Hostname: "test_hostname", 17 } 18 19 result1 := o 20 result2 := o 21 result3 := o 22 23 o.Id = "0" 24 result1.Id = "1" 25 result2.Id = "2" 26 result3.Id = "3" 27 result3.Hostname = "something_diff" 28 29 assert.True(t, o.IsEqual(&result1)) 30 31 list := make([]*ClusterDiscovery, 0) 32 list = append(list, &o) 33 list = append(list, &result1) 34 list = append(list, &result2) 35 list = append(list, &result3) 36 37 rlist := FilterClusterDiscovery(list, func(in *ClusterDiscovery) bool { 38 return !o.IsEqual(in) 39 }) 40 41 assert.Len(t, rlist, 1) 42 43 o.AutoFillHostname() 44 o.Hostname = "" 45 o.AutoFillHostname() 46 47 o.AutoFillIPAddress("", "") 48 o.Hostname = "" 49 o.AutoFillIPAddress("", "") 50} 51