Skip to content

<first commit>#1

Open
anburbaeva wants to merge 1 commit intomainfrom
first-iteration
Open

<first commit>#1
anburbaeva wants to merge 1 commit intomainfrom
first-iteration

Conversation

@anburbaeva
Copy link
Copy Markdown
Owner

No description provided.

Copy link
Copy Markdown

@ivannizh ivannizh left a comment

Choose a reason for hiding this comment

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

Анастасия, привет! Тесты проходят, работа принимается.

Небольшое замечание - коммиты лучше называть как-то понятнее для других. make test suits, например

Если скучно ждать следующего спринта, то можно изучить и сделать табличные тесты, вот пример как это можно сделать.

Comment thread precode_test.go
"github.com/stretchr/testify/assert"
)

func performRequest(t *testing.T, method, path string) *httptest.ResponseRecorder {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Отлично, что общий код вынесен в отдельную функцию

Comment thread precode_test.go

func performRequest(t *testing.T, method, path string) *httptest.ResponseRecorder {
req, err := http.NewRequest(method, path, nil)
assert.NoError(t, err)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Здесь, наверное, лучше бы подошел require, так как посое него код теста останавливается

Comment thread precode_test.go
responseRecorder := performRequest(t, "GET", "/cafe?count=4&city=moscow")

assert.Equal(t, http.StatusOK, responseRecorder.Code)
assert.NotEmpty(t, responseRecorder.Body.String())
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

По ТЗ так и надо, но лучше хотя бы просто посчитать сколько элемнтов нам вернули

Comment thread precode_test.go
responseRecorder := performRequest(t, "GET", "/cafe?count=4&city=nonexistent")

assert.Equal(t, http.StatusBadRequest, responseRecorder.Code)
assert.Contains(t, responseRecorder.Body.String(), "wrong city value")
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Contains ищет подстроку в строке, то есть ответ HI, wrong city value тоже пододёт. ЛУчше в данном случае использовать Equal

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

Successfully merging this pull request may close these issues.

2 participants