Skip to content

Commit

Permalink
change require.Equal to assert.JSONEq
Browse files Browse the repository at this point in the history
  • Loading branch information
yun-yeo committed Jul 8, 2021
1 parent 950f992 commit 04fe3cd
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 44 deletions.
3 changes: 2 additions & 1 deletion x/market/legacy/v05/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -59,5 +60,5 @@ func TestMigrate(t *testing.T) {
}
}`

require.Equal(t, expected, string(indentedBz))
assert.JSONEq(t, expected, string(indentedBz))
}
23 changes: 2 additions & 21 deletions x/oracle/legacy/v05/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -236,25 +237,5 @@ func TestMigrate(t *testing.T) {
]
}`

areEqualJSON(t, expected, string(indentedBz))
}

func areEqualJSON(t *testing.T, s1, s2 string) {
var o1 interface{}
var o2 interface{}

var err error
err = json.Unmarshal([]byte(s1), &o1)
require.NoError(t, err)

err = json.Unmarshal([]byte(s2), &o2)
require.NoError(t, err)

bz1, err := json.Marshal(o1)
require.NoError(t, err)

bz2, err := json.Marshal(o2)
require.NoError(t, err)

require.Equal(t, bz1, bz2)
assert.JSONEq(t, expected, string(indentedBz))
}
23 changes: 2 additions & 21 deletions x/treasury/legacy/v05/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -181,25 +182,5 @@ func TestMigrate(t *testing.T) {
"tax_rate": "0.020000000000000000"
}`

areEqualJSON(t, expected, string(indentedBz))
}

func areEqualJSON(t *testing.T, s1, s2 string) {
var o1 interface{}
var o2 interface{}

var err error
err = json.Unmarshal([]byte(s1), &o1)
require.NoError(t, err)

err = json.Unmarshal([]byte(s2), &o2)
require.NoError(t, err)

bz1, err := json.Marshal(o1)
require.NoError(t, err)

bz2, err := json.Marshal(o2)
require.NoError(t, err)

require.Equal(t, bz1, bz2)
assert.JSONEq(t, expected, string(indentedBz))
}
3 changes: 2 additions & 1 deletion x/wasm/legacy/v05/migrate_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"
"testing"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"

"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -195,5 +196,5 @@ func TestMigrate(t *testing.T) {
"max_contract_size": "614400"
}
}`
require.Equal(t, expected, string(indentedBz))
assert.JSONEq(t, expected, string(indentedBz))
}

0 comments on commit 04fe3cd

Please sign in to comment.