Skip to content

Commit

Permalink
fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
vincentysc committed Dec 1, 2024
1 parent 1dd6a80 commit d5b0fc8
Show file tree
Hide file tree
Showing 11 changed files with 22 additions and 22 deletions.
4 changes: 2 additions & 2 deletions projection/account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions projection/account_message/account_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions projection/ibc_channel/ibc_channel_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions projection/proposal/proposal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions projection/raw_transaction/raw_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions projection/transaction/transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions usecase/coin/coin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Check failure on line 678 in usecase/coin/coin_test.go

View workflow job for this annotation

GitHub Actions / lint

suite-extra-assert-call: need to simplify the assertion to s.NoError (testifylint)

Check failure on line 678 in usecase/coin/coin_test.go

View workflow job for this annotation

GitHub Actions / lint

suite-extra-assert-call: need to simplify the assertion to s.NoError (testifylint)
s.Require().Equal(tc.expected, res, "coin parsing was incorrect, tc #%d", tcIndex)
}
}
Expand Down Expand Up @@ -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)
}
}

Expand Down
2 changes: 1 addition & 1 deletion usecase/coin/dec_coin_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions usecase/coin/decimal_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion usecase/coin/int_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d5b0fc8

Please sign in to comment.