diff --git a/projection/account/account_test.go b/projection/account/account_test.go index 269648116..241d553cf 100644 --- a/projection/account/account_test.go +++ b/projection/account/account_test.go @@ -14,8 +14,8 @@ import ( account_view "github.com/crypto-com/chain-indexing/projection/account/view" "github.com/crypto-com/chain-indexing/usecase/coin" event_usecase "github.com/crypto-com/chain-indexing/usecase/event" - "github.com/stretchr/testify/assert" testify_mock "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" ) func NewAccountProjection(rdbConn rdb.Conn, client cosmosapp.Client) *account.Account { @@ -237,7 +237,7 @@ func TestAccount_HandleEvents(t *testing.T) { projection := NewAccountProjection(mockRDbConn, mockClient) err := projection.HandleEvents(1, tc.Events) - assert.NoError(t, err) + require.NoError(t, err) for _, m := range mocks { m.AssertExpectations(t) diff --git a/projection/account_message/account_message_test.go b/projection/account_message/account_message_test.go index 8d6eb55cc..5a638ecef 100644 --- a/projection/account_message/account_message_test.go +++ b/projection/account_message/account_message_test.go @@ -19,8 +19,8 @@ import ( "github.com/crypto-com/chain-indexing/usecase/model" usecase_model "github.com/crypto-com/chain-indexing/usecase/model" ibc_model "github.com/crypto-com/chain-indexing/usecase/model/ibc" - "github.com/stretchr/testify/assert" testify_mock "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" ) func NewAccountMessageProjection(rdbConn rdb.Conn) *account_message.AccountMessage { @@ -5001,7 +5001,7 @@ func TestAccountMessage_HandleEvents(t *testing.T) { projection := NewAccountMessageProjection(mockRDbConn) err := projection.HandleEvents(1, tc.Events) - assert.NoError(t, err) + require.NoError(t, err) for _, m := range mocks { m.AssertExpectations(t) diff --git a/projection/account_raw_transaction/account_raw_transaction_test.go b/projection/account_raw_transaction/account_raw_transaction_test.go index dad453ecd..3d51a5b77 100644 --- a/projection/account_raw_transaction/account_raw_transaction_test.go +++ b/projection/account_raw_transaction/account_raw_transaction_test.go @@ -8,8 +8,8 @@ import ( "github.com/crypto-com/chain-indexing/external/primptr" "github.com/crypto-com/chain-indexing/projection/account_raw_transaction" account_raw_transaction_view "github.com/crypto-com/chain-indexing/projection/account_raw_transaction/view" - "github.com/stretchr/testify/assert" testify_mock "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" "github.com/crypto-com/chain-indexing/appinterface/rdb" "github.com/crypto-com/chain-indexing/appinterface/rdb/test" @@ -444,7 +444,7 @@ func TestAccountRawTransaction_HandleEvents(t *testing.T) { projection := NewAccountRawTransactionProjection(mockRDbConn) err := projection.HandleEvents(1, tc.Events) - assert.NoError(t, err) + require.NoError(t, err) for _, m := range mocks { m.AssertExpectations(t) diff --git a/projection/ibc_channel/ibc_channel_test.go b/projection/ibc_channel/ibc_channel_test.go index 9601cd80c..39a49775b 100644 --- a/projection/ibc_channel/ibc_channel_test.go +++ b/projection/ibc_channel/ibc_channel_test.go @@ -11,8 +11,8 @@ import ( "github.com/crypto-com/chain-indexing/external/utctime" ibc_channel_view "github.com/crypto-com/chain-indexing/projection/ibc_channel/view" "github.com/crypto-com/chain-indexing/usecase/coin" - "github.com/stretchr/testify/assert" testify_mock "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" "github.com/crypto-com/chain-indexing/appinterface/rdb" "github.com/crypto-com/chain-indexing/appinterface/rdb/test" @@ -1539,7 +1539,7 @@ func TestIBCChannel_HandleEvents(t *testing.T) { projection := NewIBCChannelProjection(mockRDbConn) err := projection.HandleEvents(1, tc.Events) - assert.NoError(t, err) + require.NoError(t, err) for _, m := range mocks { m.AssertExpectations(t) diff --git a/projection/proposal/proposal_test.go b/projection/proposal/proposal_test.go index 03e198899..f60e033db 100644 --- a/projection/proposal/proposal_test.go +++ b/projection/proposal/proposal_test.go @@ -8,8 +8,8 @@ import ( "time" sq "github.com/Masterminds/squirrel" - "github.com/stretchr/testify/assert" testify_mock "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" "github.com/crypto-com/chain-indexing/appinterface/cosmosapp" "github.com/crypto-com/chain-indexing/appinterface/projection/rdbparambase" @@ -2618,7 +2618,7 @@ func TestProposal_HandleEvents(t *testing.T) { projection := NewProposalProjection(mockRDbConn, mockClient) err := projection.HandleEvents(1, tc.Events) - assert.NoError(t, err) + require.NoError(t, err) for _, m := range mocks { m.AssertExpectations(t) diff --git a/projection/raw_transaction/raw_transaction_test.go b/projection/raw_transaction/raw_transaction_test.go index a8e81779f..3e6fcc17e 100644 --- a/projection/raw_transaction/raw_transaction_test.go +++ b/projection/raw_transaction/raw_transaction_test.go @@ -8,8 +8,8 @@ import ( "github.com/crypto-com/chain-indexing/external/primptr" "github.com/crypto-com/chain-indexing/projection/raw_transaction" raw_transaction_view "github.com/crypto-com/chain-indexing/projection/raw_transaction/view" - "github.com/stretchr/testify/assert" testify_mock "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" "github.com/crypto-com/chain-indexing/appinterface/rdb" "github.com/crypto-com/chain-indexing/appinterface/rdb/test" @@ -361,7 +361,7 @@ func TestRawTransaction_HandleEvents(t *testing.T) { projection := NewRawTransactionProjection(mockRDbConn) err := projection.HandleEvents(1, tc.Events) - assert.NoError(t, err) + require.NoError(t, err) for _, m := range mocks { m.AssertExpectations(t) diff --git a/projection/transaction/transaction_test.go b/projection/transaction/transaction_test.go index 885d443eb..8ed619eec 100644 --- a/projection/transaction/transaction_test.go +++ b/projection/transaction/transaction_test.go @@ -6,8 +6,8 @@ import ( sq "github.com/Masterminds/squirrel" "github.com/crypto-com/chain-indexing/external/primptr" - "github.com/stretchr/testify/assert" testify_mock "github.com/stretchr/testify/mock" + "github.com/stretchr/testify/require" "github.com/crypto-com/chain-indexing/appinterface/rdb" "github.com/crypto-com/chain-indexing/appinterface/rdb/test" @@ -381,7 +381,7 @@ func TestTransaction_HandleEvents(t *testing.T) { projection := NewTransactionProjection(mockRDbConn) err := projection.HandleEvents(1, tc.Events) - assert.NoError(t, err) + require.NoError(t, err) for _, m := range mocks { m.AssertExpectations(t) diff --git a/usecase/coin/coin_test.go b/usecase/coin/coin_test.go index ba6e4dd16..32b62a9d3 100644 --- a/usecase/coin/coin_test.go +++ b/usecase/coin/coin_test.go @@ -675,7 +675,7 @@ func (s *coinTestSuite) TestParseCoins() { res, err := sdk.ParseCoinsNormalized(tc.input) if !tc.valid { s.Require().Error(err, "%s: %#v. tc #%d", tc.input, res, tcIndex) - } else if s.Assert().Nil(err, "%s: %+v", tc.input, err) { + } else if s.Assert().NoError(err, "%s: %+v", tc.input, err) { s.Require().Equal(tc.expected, res, "coin parsing was incorrect, tc #%d", tcIndex) } } @@ -900,7 +900,7 @@ func (s *coinTestSuite) TestCoinsIsAnyGT() { } for _, tc := range tests { - s.Require().True(tc.expPass == tc.coinsA.IsAnyGT(tc.coinsB), tc.name) + s.Require().Equal(tc.expPass, tc.coinsA.IsAnyGT(tc.coinsB), tc.name) } } diff --git a/usecase/coin/dec_coin_test.go b/usecase/coin/dec_coin_test.go index 6a5fec6c2..ff1cb6927 100644 --- a/usecase/coin/dec_coin_test.go +++ b/usecase/coin/dec_coin_test.go @@ -547,7 +547,7 @@ func (s *decCoinTestSuite) TestNewDecCoinsWithIsValid() { func (s *decCoinTestSuite) TestDecCoins_AddDecCoinWithIsValid() { lengthTestDecCoins := sdk.NewDecCoins().Add(sdk.NewDecCoin("mytoken", sdk.NewInt(10))).Add(sdk.DecCoin{Denom: "BTC", Amount: sdk.NewDec(10)}) - s.Require().Equal(2, len(lengthTestDecCoins), "should be 2") + s.Require().Len(lengthTestDecCoins, 2, "should be 2") tests := []struct { coin sdk.DecCoins diff --git a/usecase/coin/decimal_test.go b/usecase/coin/decimal_test.go index bc0f2efdb..e18ef757c 100644 --- a/usecase/coin/decimal_test.go +++ b/usecase/coin/decimal_test.go @@ -62,18 +62,18 @@ func (s *decimalTestSuite) TestNewDecFromStr() { for tcIndex, tc := range tests { res, err := sdk.NewDecFromStr(tc.decimalStr) if tc.expErr { - s.Require().NotNil(err, "error expected, decimalStr %v, tc %v", tc.decimalStr, tcIndex) + s.Require().Error(err, "error expected, decimalStr %v, tc %v", tc.decimalStr, tcIndex) } else { - s.Require().Nil(err, "unexpected error, decimalStr %v, tc %v", tc.decimalStr, tcIndex) + s.Require().NoError(err, "unexpected error, decimalStr %v, tc %v", tc.decimalStr, tcIndex) s.Require().True(res.Equal(tc.exp), "equality was incorrect, res %v, exp %v, tc %v", res, tc.exp, tcIndex) } // negative tc res, err = sdk.NewDecFromStr("-" + tc.decimalStr) if tc.expErr { - s.Require().NotNil(err, "error expected, decimalStr %v, tc %v", tc.decimalStr, tcIndex) + s.Require().Error(err, "error expected, decimalStr %v, tc %v", tc.decimalStr, tcIndex) } else { - s.Require().Nil(err, "unexpected error, decimalStr %v, tc %v", tc.decimalStr, tcIndex) + s.Require().NoError(err, "unexpected error, decimalStr %v, tc %v", tc.decimalStr, tcIndex) exp := tc.exp.Mul(sdk.NewDec(-1)) s.Require().True(res.Equal(exp), "equality was incorrect, res %v, exp %v, tc %v", res, exp, tcIndex) } diff --git a/usecase/coin/int_test.go b/usecase/coin/int_test.go index 106d97c55..1249bc852 100644 --- a/usecase/coin/int_test.go +++ b/usecase/coin/int_test.go @@ -284,7 +284,7 @@ func (s *intTestSuite) TestEncodingTableInt() { for tcnum, tc := range cases { bz, err := tc.i.MarshalJSON() - s.Require().Nil(err, "Error marshaling Int. tc #%d, err %s", tcnum, err) + s.Require().NoError(err, "Error marshaling Int. tc #%d, err %s", tcnum, err) s.Require().Equal(tc.jsonBz, bz, "Marshaled value is different from exported. tc #%d", tcnum) err = (&i).UnmarshalJSON(bz)