prefer NoError/Error over Nil/NotNil
This commit is contained in:
parent
44a244b1cb
commit
dcd0cda0c6
5 changed files with 7 additions and 7 deletions
|
@ -448,9 +448,9 @@ func TestLBStatusUpdater(t *testing.T) {
|
||||||
svInfo := &runtime.ServiceInfo{}
|
svInfo := &runtime.ServiceInfo{}
|
||||||
lbsu := NewLBStatusUpdater(lb, svInfo)
|
lbsu := NewLBStatusUpdater(lb, svInfo)
|
||||||
newServer, err := url.Parse("http://foo.com")
|
newServer, err := url.Parse("http://foo.com")
|
||||||
assert.Nil(t, err)
|
assert.NoError(t, err)
|
||||||
err = lbsu.UpsertServer(newServer, roundrobin.Weight(1))
|
err = lbsu.UpsertServer(newServer, roundrobin.Weight(1))
|
||||||
assert.Nil(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, len(lbsu.Servers()), 1)
|
assert.Equal(t, len(lbsu.Servers()), 1)
|
||||||
assert.Equal(t, len(lbsu.BalancerHandler.(*testLoadBalancer).Options()), 1)
|
assert.Equal(t, len(lbsu.BalancerHandler.(*testLoadBalancer).Options()), 1)
|
||||||
statuses := svInfo.GetAllStatus()
|
statuses := svInfo.GetAllStatus()
|
||||||
|
@ -461,7 +461,7 @@ func TestLBStatusUpdater(t *testing.T) {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
err = lbsu.RemoveServer(newServer)
|
err = lbsu.RemoveServer(newServer)
|
||||||
assert.Nil(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, len(lbsu.Servers()), 0)
|
assert.Equal(t, len(lbsu.Servers()), 0)
|
||||||
statuses = svInfo.GetAllStatus()
|
statuses = svInfo.GetAllStatus()
|
||||||
assert.Equal(t, len(statuses), 1)
|
assert.Equal(t, len(statuses), 1)
|
||||||
|
|
|
@ -1179,7 +1179,7 @@ func TestGetCertificates(t *testing.T) {
|
||||||
if test.errResult != "" {
|
if test.errResult != "" {
|
||||||
assert.EqualError(t, err, test.errResult)
|
assert.EqualError(t, err, test.errResult)
|
||||||
} else {
|
} else {
|
||||||
assert.Nil(t, err)
|
assert.NoError(t, err)
|
||||||
assert.Equal(t, test.result, tlsConfigs)
|
assert.Equal(t, test.result, tlsConfigs)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -276,7 +276,7 @@ func TestBuilder_BuildChainWithContext(t *testing.T) {
|
||||||
|
|
||||||
handlers, err := result.Then(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) }))
|
handlers, err := result.Then(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.WriteHeader(http.StatusOK) }))
|
||||||
if test.expectedError != nil {
|
if test.expectedError != nil {
|
||||||
require.NotNil(t, err)
|
require.Error(t, err)
|
||||||
require.Equal(t, test.expectedError.Error(), err.Error())
|
require.Equal(t, test.expectedError.Error(), err.Error())
|
||||||
} else {
|
} else {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -193,7 +193,7 @@ func TestManager_BuildTCP(t *testing.T) {
|
||||||
assert.EqualError(t, err, test.expectedError)
|
assert.EqualError(t, err, test.expectedError)
|
||||||
require.Nil(t, handler)
|
require.Nil(t, handler)
|
||||||
} else {
|
} else {
|
||||||
assert.Nil(t, err)
|
assert.NoError(t, err)
|
||||||
require.NotNil(t, handler)
|
require.NotNil(t, handler)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
@ -193,7 +193,7 @@ func TestManager_BuildUDP(t *testing.T) {
|
||||||
assert.EqualError(t, err, test.expectedError)
|
assert.EqualError(t, err, test.expectedError)
|
||||||
require.Nil(t, handler)
|
require.Nil(t, handler)
|
||||||
} else {
|
} else {
|
||||||
assert.Nil(t, err)
|
assert.NoError(t, err)
|
||||||
require.NotNil(t, handler)
|
require.NotNil(t, handler)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue