auth/internal/health/delivery/http/health_http_test.go

30 lines
640 B
Go
Raw Normal View History

2021-11-14 21:15:28 +00:00
package http_test
import (
"net/http"
2023-01-02 00:11:47 +00:00
"net/http/httptest"
2021-11-14 21:15:28 +00:00
"testing"
delivery "source.toby3d.me/toby3d/auth/internal/health/delivery/http"
testutil "source.toby3d.me/toby3d/auth/internal/util/testing"
2021-11-14 21:15:28 +00:00
)
func TestHandler_ServeHTTP(t *testing.T) {
2021-11-14 21:15:28 +00:00
t.Parallel()
2023-01-02 00:11:47 +00:00
req := httptest.NewRequest(http.MethodGet, "https://example.com/health", nil)
w := httptest.NewRecorder()
h := delivery.NewHandler()
h.Test = true
2021-11-14 21:15:28 +00:00
h.ServeHTTP(w, req)
2021-11-14 21:15:28 +00:00
resp := w.Result()
2023-01-02 00:11:47 +00:00
if exp := http.StatusOK; resp.StatusCode != exp {
t.Errorf("%s %s = %d, want %d", req.Method, req.RequestURI, resp.StatusCode, exp)
}
testutil.GoldenEqual(t, resp.Body)
2021-11-14 21:15:28 +00:00
}