MM-19138 - Adjust test to use require. (#12585)

* Adjust test to use require.

* Use assert instead of require.
Этот коммит содержится в:
Kevin Grandjean
2019-10-10 15:27:36 +02:00
коммит произвёл Harrison Healey
родитель 7a0d9149eb
Коммит 1635eb6006

Просмотреть файл

@@ -6,6 +6,8 @@ package model
import ( import (
"strings" "strings"
"testing" "testing"
"github.com/stretchr/testify/assert"
) )
func TestClusterDiscovery(t *testing.T) { func TestClusterDiscovery(t *testing.T) {
@@ -18,9 +20,8 @@ func TestClusterDiscovery(t *testing.T) {
json := o.ToJson() json := o.ToJson()
result1 := ClusterDiscoveryFromJson(strings.NewReader(json)) result1 := ClusterDiscoveryFromJson(strings.NewReader(json))
if result1.ClusterName != "cluster_name" { assert.NotNil(t, result1)
t.Fatal("should be set") assert.Equal(t, "cluster_name", result1.ClusterName)
}
result2 := ClusterDiscoveryFromJson(strings.NewReader(json)) result2 := ClusterDiscoveryFromJson(strings.NewReader(json))
result3 := ClusterDiscoveryFromJson(strings.NewReader(json)) result3 := ClusterDiscoveryFromJson(strings.NewReader(json))
@@ -31,9 +32,7 @@ func TestClusterDiscovery(t *testing.T) {
result3.Id = "3" result3.Id = "3"
result3.Hostname = "something_diff" result3.Hostname = "something_diff"
if !o.IsEqual(result1) { assert.True(t, o.IsEqual(result1))
t.Fatal("Should be equal")
}
list := make([]*ClusterDiscovery, 0) list := make([]*ClusterDiscovery, 0)
list = append(list, &o) list = append(list, &o)
@@ -45,9 +44,7 @@ func TestClusterDiscovery(t *testing.T) {
return !o.IsEqual(in) return !o.IsEqual(in)
}) })
if len(rlist) != 1 { assert.Len(t, rlist, 1)
t.Fatal("should only have 1 result")
}
o.AutoFillHostname() o.AutoFillHostname()
o.Hostname = "" o.Hostname = ""