Skip to content

Tests are boring#1

Open
Testbek wants to merge 3 commits intomainfrom
myFirstTest
Open

Tests are boring#1
Testbek wants to merge 3 commits intomainfrom
myFirstTest

Conversation

@Testbek
Copy link
Copy Markdown
Owner

@Testbek Testbek commented Mar 9, 2025

No description provided.

Copy link
Copy Markdown

@dirtymew dirtymew left a comment

Choose a reason for hiding this comment

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

Привет Вячеслав

по работе есть критичное замечание

код и тесты в go пишутся в разных файлах - если код в файле например precode.go то его тесты в pracode_test.go

нужно оформить код и тесты правильно

тест кейсы в целом ок описаны - там немного нужно поправить

Comment thread t_test.go Outdated
handler := http.HandlerFunc(mainHandle)
handler.ServeHTTP(responseRecorder, req)
// проверка на пустоту
require.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.

тут важен порядок - сначала код проверяем потом тело

require.Equal(t, responseRecorder.Code, http.StatusOK)
assert.NotEmpty(t, responseRecorder.Body)

Comment thread t_test.go Outdated
bodyEcpected := "wrong city value"
bodyActual := responseRecorder.Body.String()

assert.Equal(t, http.StatusBadRequest, responseRecorder.Code)
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 t_test.go
responseRecorder := httptest.NewRecorder()
handler := http.HandlerFunc(mainHandle)
handler.ServeHTTP(responseRecorder, req)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

тут код ответа тоже нужно проверять

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

тут код ответа тоже нужно проверять

Привет, Антон! Рад Вас видеть! Исправил свои ошибки по Вашим замечаниям, новая версия уже "commit". С нетерпением, жду Вашей ревью)

Copy link
Copy Markdown

@dirtymew dirtymew left a comment

Choose a reason for hiding this comment

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

Привет Вячеслав

по работе все отлично - тесты описаны и работают как надо

есть один момент обрати внимание обязательно на комметарий

Comment thread t_test.go
@@ -0,0 +1,51 @@
package main
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

файл t_test.go - нужно переименовать в precode_test.go

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