본문 바로가기

개발자의 개발괴발

검색하기
개발자의 개발괴발
프로필사진 휘발성 기억력

  • 분류 전체보기 (36)
    • 개발 (29)
      • kubernetes (6)
      • kafka (18)
      • ELK (3)
      • go (2)
    • AI (2)
    • Home Cam Service 개발하기 (5)
Guestbook
Notice
Recent Posts
Recent Comments
Link
«   2025/06   »
일 월 화 수 목 금 토
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
Tags
  • k8s
  • Golang
  • loadbalance
  • Elk
  • Kafka
  • gorm
  • http
  • go
  • kibana
  • Kubernetes
  • create topic
  • tls disable
  • eck
  • docker
  • Kafka Connect
  • gin
  • Produce
  • go test
  • Consumer
  • kafka-connect
  • broker
  • ElasticSearch
  • Helm
  • topic
  • minikube
  • 쿠버네티스
  • kafka broker
  • consumer group
  • gortsplib
  • Message
more
Archives
Today
Total
관리 메뉴
  • 글쓰기
  • 방명록
  • RSS
  • 관리

목록2025/06/01 (1)

개발자의 개발괴발

Handler test 작성

각각의 함수의 unit test도 필요하지만 http handler에도 test가 필요하다.각각의 함수가 잘 동작한다는 보장이 있어도 handler에서 에러가 날 수도 있기 때문이다.Handler test하기handler를 테스트 하는것도 handler 함수를 호출해주는 것처럼 테스트를 할 수 있다.func GetAllUsers(c *gin.Context) { // something}그러나 handler는 parameter로 *gin.Context를 받아야한다.어떻게해야할지 몰라 당황스러울 수도 있지만 다행히도 test context를 만들어서 집어넣어줄 수 있다.func GetTestGinContext() (*gin.Context, *httptest.ResponseRecorder) { w := http..

Home Cam Service 개발하기 2025. 6. 1. 21:32
이전 Prev 1 Next 다음

Blog is powered by kakao / Designed by Tistory

티스토리툴바