From 9343a7beba55518b6a17b1ec80ef065bf9c22412 Mon Sep 17 00:00:00 2001 From: Taku Shimosawa Date: Wed, 21 Jun 2017 11:33:52 -0700 Subject: [PATCH] [FAB-4913] Use the same assert package in tests This patchset replaces the uses of docker/pkg/testutil/assert with stretchr/testify/assert, which the majority of test codes are using. Change-Id: Ic47cdf3e283a9b21cf16763734520f4e1dc3597f Signed-off-by: Taku Shimosawa --- bccsp/factory/opts_test.go | 2 +- core/chaincode/platforms/golang/env_test.go | 4 ++-- core/chaincode/platforms/golang/platform_test.go | 4 ++-- gossip/state/metastate_test.go | 12 ++++++------ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/bccsp/factory/opts_test.go b/bccsp/factory/opts_test.go index cad3850a33e..7e830603392 100644 --- a/bccsp/factory/opts_test.go +++ b/bccsp/factory/opts_test.go @@ -18,7 +18,7 @@ package factory import ( "testing" - "github.com/docker/docker/pkg/testutil/assert" + "github.com/stretchr/testify/assert" ) func TestFactoryOptsFactoryName(t *testing.T) { diff --git a/core/chaincode/platforms/golang/env_test.go b/core/chaincode/platforms/golang/env_test.go index 28116cc84ea..90e4c2dd260 100644 --- a/core/chaincode/platforms/golang/env_test.go +++ b/core/chaincode/platforms/golang/env_test.go @@ -20,7 +20,7 @@ import ( "os" "testing" - "github.com/docker/docker/pkg/testutil/assert" + "github.com/stretchr/testify/assert" ) func Test_splitEnvPath(t *testing.T) { @@ -30,7 +30,7 @@ func Test_splitEnvPath(t *testing.T) { func Test_getGoEnv(t *testing.T) { goenv, err := getGoEnv() - assert.NilError(t, err) + assert.NoError(t, err) _, ok := goenv["GOPATH"] assert.Equal(t, ok, true) diff --git a/core/chaincode/platforms/golang/platform_test.go b/core/chaincode/platforms/golang/platform_test.go index 21d9519c4af..6548dc58297 100644 --- a/core/chaincode/platforms/golang/platform_test.go +++ b/core/chaincode/platforms/golang/platform_test.go @@ -26,10 +26,10 @@ import ( "testing" "time" - "github.com/docker/docker/pkg/testutil/assert" "github.com/hyperledger/fabric/core/config" pb "github.com/hyperledger/fabric/protos/peer" "github.com/spf13/viper" + "github.com/stretchr/testify/assert" ) func testerr(err error, succ bool) error { @@ -154,7 +154,7 @@ func Test_DeploymentPayload(t *testing.T) { } payload, err := platform.GetDeploymentPayload(spec) - assert.NilError(t, err) + assert.NoError(t, err) t.Logf("payload size: %d", len(payload)) diff --git a/gossip/state/metastate_test.go b/gossip/state/metastate_test.go index 232248d693c..f508268d538 100644 --- a/gossip/state/metastate_test.go +++ b/gossip/state/metastate_test.go @@ -19,8 +19,8 @@ package state import ( "testing" - "github.com/docker/docker/pkg/testutil/assert" "github.com/hyperledger/fabric/gossip/util" + "github.com/stretchr/testify/assert" ) func init() { @@ -44,7 +44,7 @@ func TestNodeMetastateImpl_Bytes(t *testing.T) { metastate := NewNodeMetastate(0) // Encode state into bytes and check there is no errors _, err := metastate.Bytes() - assert.NilError(t, err) + assert.NoError(t, err) } // Check the deserialization of the meta stats structure @@ -52,7 +52,7 @@ func TestNodeMetastate_FromBytes(t *testing.T) { metastate := NewNodeMetastate(0) // Serialize into bytes array bytes, err := metastate.Bytes() - assert.NilError(t, err) + assert.NoError(t, err) if bytes == nil { t.Fatal("Was not able to serialize meta state into byte array.") } @@ -60,14 +60,14 @@ func TestNodeMetastate_FromBytes(t *testing.T) { // Deserialize back and check, that state still have same // height value state, err := FromBytes(bytes) - assert.NilError(t, err) + assert.NoError(t, err) assert.Equal(t, state.Height(), uint64(0)) // Update state to the new height and serialize it again state.Update(17) bytes, err = state.Bytes() - assert.NilError(t, err) + assert.NoError(t, err) if bytes == nil { t.Fatal("Was not able to serialize meta state into byte array.") } @@ -75,6 +75,6 @@ func TestNodeMetastate_FromBytes(t *testing.T) { // Restore state from byte array and validate // that stored height is still the same updatedState, err := FromBytes(bytes) - assert.NilError(t, err) + assert.NoError(t, err) assert.Equal(t, updatedState.Height(), uint64(17)) }