Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Неправильно работает режим IgnoreArraysOrdering #97

Closed
Alexey19 opened this issue Sep 10, 2021 · 2 comments
Closed

Comments

@Alexey19
Copy link
Contributor

Alexey19 commented Sep 10, 2021

Один из наших тестов фейлится из-за того, что сравнение с IgnoreArraysOrdering периодически неправильно производит сравнение. Проще всего воспроизвести, если в тестах "https://github.com/lamoda/gonkey/blob/master/compare/compare_test.go" поставить :

var complexJson1 = `
{
  "data": [
    {
      "name": "n222"
    },
    {
      "name": "n111"
    }
  ]
}
`
var complexJson2 = `
{
  "data": [
    {
      "message": "m555",
      "name": "n222"
    },
    {
      "message": "m777",
      "name": "n111"
    }
  ]
}
`

и в CompareParams прописать опцию IgnoreArraysOrdering: true.

Ну и в тесте поправить TestCompareEqualComplexJson:

func TestCompareEqualComplexJson(t *testing.T) {
	var json1, json2 interface{}
	json.Unmarshal([]byte(complexJson1), &json1)
	json.Unmarshal([]byte(complexJson1), &json2)          <----- тут прописать complexJson2
	errors := Compare(json1, json2, CompareParams{})
	if len(errors) != 0 {
		t.Error(
			"must return no errors",
			fmt.Sprintf("got result: %v", errors),
		)
		t.Fail()
	}
}
@Alexey19
Copy link
Contributor Author

Исправил алгоритм в #98

@Alexey19
Copy link
Contributor Author

fixed in 1.5.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant