Skip to content

Commit 9343a7b

Browse files
committed
[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 <[email protected]>
1 parent cefe788 commit 9343a7b

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

bccsp/factory/opts_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ package factory
1818
import (
1919
"testing"
2020

21-
"github.com/docker/docker/pkg/testutil/assert"
21+
"github.com/stretchr/testify/assert"
2222
)
2323

2424
func TestFactoryOptsFactoryName(t *testing.T) {

core/chaincode/platforms/golang/env_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import (
2020
"os"
2121
"testing"
2222

23-
"github.com/docker/docker/pkg/testutil/assert"
23+
"github.com/stretchr/testify/assert"
2424
)
2525

2626
func Test_splitEnvPath(t *testing.T) {
@@ -30,7 +30,7 @@ func Test_splitEnvPath(t *testing.T) {
3030

3131
func Test_getGoEnv(t *testing.T) {
3232
goenv, err := getGoEnv()
33-
assert.NilError(t, err)
33+
assert.NoError(t, err)
3434

3535
_, ok := goenv["GOPATH"]
3636
assert.Equal(t, ok, true)

core/chaincode/platforms/golang/platform_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ import (
2626
"testing"
2727
"time"
2828

29-
"github.com/docker/docker/pkg/testutil/assert"
3029
"github.com/hyperledger/fabric/core/config"
3130
pb "github.com/hyperledger/fabric/protos/peer"
3231
"github.com/spf13/viper"
32+
"github.com/stretchr/testify/assert"
3333
)
3434

3535
func testerr(err error, succ bool) error {
@@ -154,7 +154,7 @@ func Test_DeploymentPayload(t *testing.T) {
154154
}
155155

156156
payload, err := platform.GetDeploymentPayload(spec)
157-
assert.NilError(t, err)
157+
assert.NoError(t, err)
158158

159159
t.Logf("payload size: %d", len(payload))
160160

gossip/state/metastate_test.go

+6-6
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ package state
1919
import (
2020
"testing"
2121

22-
"github.com/docker/docker/pkg/testutil/assert"
2322
"github.com/hyperledger/fabric/gossip/util"
23+
"github.com/stretchr/testify/assert"
2424
)
2525

2626
func init() {
@@ -44,37 +44,37 @@ func TestNodeMetastateImpl_Bytes(t *testing.T) {
4444
metastate := NewNodeMetastate(0)
4545
// Encode state into bytes and check there is no errors
4646
_, err := metastate.Bytes()
47-
assert.NilError(t, err)
47+
assert.NoError(t, err)
4848
}
4949

5050
// Check the deserialization of the meta stats structure
5151
func TestNodeMetastate_FromBytes(t *testing.T) {
5252
metastate := NewNodeMetastate(0)
5353
// Serialize into bytes array
5454
bytes, err := metastate.Bytes()
55-
assert.NilError(t, err)
55+
assert.NoError(t, err)
5656
if bytes == nil {
5757
t.Fatal("Was not able to serialize meta state into byte array.")
5858
}
5959

6060
// Deserialize back and check, that state still have same
6161
// height value
6262
state, err := FromBytes(bytes)
63-
assert.NilError(t, err)
63+
assert.NoError(t, err)
6464

6565
assert.Equal(t, state.Height(), uint64(0))
6666

6767
// Update state to the new height and serialize it again
6868
state.Update(17)
6969
bytes, err = state.Bytes()
70-
assert.NilError(t, err)
70+
assert.NoError(t, err)
7171
if bytes == nil {
7272
t.Fatal("Was not able to serialize meta state into byte array.")
7373
}
7474

7575
// Restore state from byte array and validate
7676
// that stored height is still the same
7777
updatedState, err := FromBytes(bytes)
78-
assert.NilError(t, err)
78+
assert.NoError(t, err)
7979
assert.Equal(t, updatedState.Height(), uint64(17))
8080
}

0 commit comments

Comments
 (0)