Skip to content

Commit

Permalink
config: Use assert.JSONEq in JSON test
Browse files Browse the repository at this point in the history
When comparing strings with JSON content, assert.JSONEq is better than
assert.Equal as it will give better output when the 2 strings don't
match, and it tests for equivalence, not strict equality. This means
changes in field order is not a failure for example.
  • Loading branch information
cfergeau committed Aug 22, 2023
1 parent 6931f23 commit 98553ed
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/config/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func testJSON(t *testing.T, test *jsonTest) {
vm := test.newVM(t)
data, err := json.Marshal(vm)
require.NoError(t, err)
require.Equal(t, test.expectedJSON, string(data))
require.JSONEq(t, test.expectedJSON, string(data))

var unmarshalledVM VirtualMachine
err = json.Unmarshal([]byte(test.expectedJSON), &unmarshalledVM)
Expand Down

0 comments on commit 98553ed

Please sign in to comment.