Skip to content

Commit

Permalink
[FAB-4913] Use the same assert package in tests
Browse files Browse the repository at this point in the history
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 <taku.shimosawa@hal.hitachi.com>
  • Loading branch information
shimos committed Jun 21, 2017
1 parent cefe788 commit 9343a7b
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bccsp/factory/opts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions core/chaincode/platforms/golang/env_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions core/chaincode/platforms/golang/platform_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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))

Expand Down
12 changes: 6 additions & 6 deletions gossip/state/metastate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -44,37 +44,37 @@ 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
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.")
}

// 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.")
}

// 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))
}

0 comments on commit 9343a7b

Please sign in to comment.