Conversation
dirtymew
left a comment
There was a problem hiding this comment.
Степан
PR оформлен как надо - отлично
по работе есть критичное замечания
тесты пишутся в файлах с суффиксом _test - те если код в precode.go то тесты в precode_test.go
команда go test ./... должна запускать все написанные тесты и они должны проходить успешно
| func TestMainHandlerCorrectRequest(t *testing.T) { | ||
| req := httptest.NewRequest(http.MethodGet, "/cafe?city=moscow&count=2", nil) | ||
| rr := httptest.NewRecorder() | ||
| mainHandle(rr, req) |
There was a problem hiding this comment.
неверно нужно запрос "послать" через сервер
примерно так:
responseRecorder := httptest.NewRecorder()
handler := http.HandlerFunc(mainHandle)
handler.ServeHTTP(responseRecorder, req)
dirtymew
left a comment
There was a problem hiding this comment.
Привет Степан
кажется запутался с git
код не компилируется в ветке и тесты не запускаются
еще раз код сервера в одном файле например precode.go или main.go
тесты в другом
код должен быть компилируемым и тесты запускаться и проходить по команде go test ./...
dirtymew
left a comment
There was a problem hiding this comment.
Степан
работу принимаю - но все еще остались замечания
| @@ -0,0 +1,44 @@ | |||
| package main | |||
There was a problem hiding this comment.
❯ go test ./...
./...
pattern ./...: directory prefix . does not contain main module or its selected dependencies
FAIL ./... [setup failed]
FAIL
There was a problem hiding this comment.
go mod init test
go mod tidy
❯ go test ./...
ok test 0.366s
No description provided.