<first commit>#1
Conversation
There was a problem hiding this comment.
Анастасия, привет! Тесты проходят, работа принимается.
Небольшое замечание - коммиты лучше называть как-то понятнее для других. make test suits, например
Если скучно ждать следующего спринта, то можно изучить и сделать табличные тесты, вот пример как это можно сделать.
| "github.com/stretchr/testify/assert" | ||
| ) | ||
|
|
||
| func performRequest(t *testing.T, method, path string) *httptest.ResponseRecorder { |
There was a problem hiding this comment.
Отлично, что общий код вынесен в отдельную функцию
|
|
||
| func performRequest(t *testing.T, method, path string) *httptest.ResponseRecorder { | ||
| req, err := http.NewRequest(method, path, nil) | ||
| assert.NoError(t, err) |
There was a problem hiding this comment.
Здесь, наверное, лучше бы подошел require, так как посое него код теста останавливается
| responseRecorder := performRequest(t, "GET", "/cafe?count=4&city=moscow") | ||
|
|
||
| assert.Equal(t, http.StatusOK, responseRecorder.Code) | ||
| assert.NotEmpty(t, responseRecorder.Body.String()) |
There was a problem hiding this comment.
По ТЗ так и надо, но лучше хотя бы просто посчитать сколько элемнтов нам вернули
| 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") |
There was a problem hiding this comment.
Contains ищет подстроку в строке, то есть ответ HI, wrong city value тоже пододёт. ЛУчше в данном случае использовать Equal
No description provided.