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

New: ignore db ordering in dbResponse feature #154

Merged
merged 3 commits into from
May 26, 2022

Conversation

ikramanop
Copy link

Добавлен новый тип comparisonParams - ignoreDbOrdering, который может использоваться для проверки результата dbQuery не по порядку

@leorush
Copy link
Contributor

leorush commented May 6, 2022

@ikramanop, может ещё тесты добавить?

@keyclaim
Copy link
Contributor

keyclaim commented May 7, 2022

Да, тесты можно в таком формате response_header_test.go

@ikramanop
Copy link
Author

@ikramanop, может ещё тесты добавить?

Добавил простенькие тесты.
Правда, пришлось изменить сигнатуры сравнивающих функций, чтобы избавиться от зависимости в виде TestInterface

@@ -72,35 +77,97 @@ func (c *ResponseDbChecker) Check(t models.TestInterface, result *models.Result)
return errors, nil
}

func compareDbResp(t models.TestInterface, result *models.Result) ([]error, error) {
func compareDbRespWithoutOrdering(expected, actual []string, testName string) ([]error, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

мне кажется, что можно сделать проще и читабельнее в разы, просто отредактировав исходную функцию проверки

import (
     ...
     "sort"
     ...
)
...

func compareDbResp(expected, actual []string, testName string, query interface{}, reorder bool) ([]error, error) {
	var errors []error
	var actualJson interface{}
	var expectedJson interface{}
	
	if reorder {
	    sort.Strings(expected)
	    sort.Strings(actual)
	}
	...

@Cdayz Cdayz self-requested a review May 12, 2022 10:24
@Cdayz Cdayz added enhancement New feature or request minor release as minor labels May 26, 2022
@Cdayz Cdayz merged commit c909012 into lamoda:master May 26, 2022
@github-actions
Copy link

🚀 PR was released in v1.16.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request minor release as minor released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants