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

Hw15 calendar #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Hw15 calendar #15

wants to merge 1 commit into from

Conversation

lomoval
Copy link
Owner

@lomoval lomoval commented Feb 26, 2022

Домашнее задание №15 «Докеризация и интеграционное тестирование Календаря»

Критерии оценки

  • Проект полностью запускается и останавливается с помощью make up / make down - 3 балла
  • Интеграционные тесты запускаются с помощью make integration-tests. Команда возвращает верный код ответа - 1 балл

Интеграционные тесты покрывают бизнес сценарии:

  • добавление события и обработка бизнес ошибок - 2 балла
  • получение листинга событий на день/неделю/месяц - 2 балла
  • отправка уведомлений - 2 балла

Зачёт от 7 баллов


make build-img-all - собирает нужные образы
make up - поднимает все сервисы (проводит миграцию) - exposed-порты GRPC: 10081, HTTP: 10080
make integration-tests - запускает интеграционные тесты.

Вывод тестов:

Creating network "build_default" with the default driver
--------------------------------------------------------
 docker-compose-wait 2.7.2
---------------------------
Starting with configuration:
 - Hosts to be waiting for: [calendar:10080]
 - Timeout before failure: 30 seconds 
 - TCP connection timeout before retry: 5 seconds 
 - Sleeping time before checking for hosts availability: 0 seconds
 - Sleeping time once all hosts are available: 0 seconds
 - Sleeping time between retries: 1 seconds
--------------------------------------------------------
Checking availability of calendar:10080
Host calendar:10080 not yet available...
Host calendar:10080 not yet available...
Host calendar:10080 is now available!
--------------------------------------------------------
docker-compose-wait - Everything's fine, the application can now start!
--------------------------------------------------------
=== RUN   TestStorage
=== RUN   TestStorage/add_event
=== RUN   TestStorage/update_get_event
=== RUN   TestStorage/remove_event
--- PASS: TestStorage (0.11s)
    --- PASS: TestStorage/add_event (0.04s)
    --- PASS: TestStorage/update_get_event (0.04s)
    --- PASS: TestStorage/remove_event (0.03s)
=== RUN   TestGatewayGetEvents
=== RUN   TestGatewayGetEvents/get_day
=== RUN   TestGatewayGetEvents/get_week
=== RUN   TestGatewayGetEvents/get_month
=== RUN   TestGatewayGetEvents/get_month_28_days
--- PASS: TestGatewayGetEvents (0.23s)
    --- PASS: TestGatewayGetEvents/get_day (0.00s)
    --- PASS: TestGatewayGetEvents/get_week (0.00s)
    --- PASS: TestGatewayGetEvents/get_month (0.01s)
    --- PASS: TestGatewayGetEvents/get_month_28_days (0.01s)
=== RUN   TestGatewayErrors
=== RUN   TestGatewayErrors/add_no_empty_event
=== RUN   TestGatewayErrors/add_no_event
=== RUN   TestGatewayErrors/remove_non_exists_event
=== RUN   TestGatewayErrors/update_non_exists_event
--- PASS: TestGatewayErrors (0.02s)
    --- PASS: TestGatewayErrors/add_no_empty_event (0.00s)
    --- PASS: TestGatewayErrors/add_no_event (0.01s)
    --- PASS: TestGatewayErrors/remove_non_exists_event (0.00s)
    --- PASS: TestGatewayErrors/update_non_exists_event (0.00s)
PASS

Copy link
Collaborator

@sshaplygin sshaplygin left a comment

Choose a reason for hiding this comment

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

Здравствуйте. Спасибо за выполненное задание. Отличная работа

Итого: 10/10

Нотация:
👍 - Классное, не обычное, оригинальное решение

👀 - Стоит обратить внимание. Рекомендация, которая не влияет на успешность выполнения задания

🔥 - Критичное замечание, которое влияет на сдачу задания

run-img: build-img
docker run $(DOCKER_IMG)

up:
docker-compose -f build/docker-compose.yaml up
# docker-compose run postgres goose postgres "dbname=postgres sslmode=disable host=${PG_HOST} port=${PG_PORT} password=${PG_PASS} user=${PG_USER}" up
Copy link
Collaborator

Choose a reason for hiding this comment

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

👀

Не стоит в PR оставлять мертвый код

t.Run("add event", func(t *testing.T) {
require.NoError(t, cleanupDB())
event := createEvent()
jsonStr, err := json.Marshal(apiStruct{Event: event})
Copy link
Collaborator

Choose a reason for hiding this comment

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

👍

Хорошо, что вы используете в тестах везде, где можно проверку ошибок - require.NoError(t, err)


resp := sendRequest(t, "POST", grpcGatewayURL, "AddEvent", jsonStr)
defer resp.Body.Close()
require.Equal(t, 200, resp.StatusCode)
Copy link
Collaborator

Choose a reason for hiding this comment

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

👀

константу статус кода можно достать из пакета net/http -> http.StatusOK

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