2021-11-14 21:15:28 +00:00
|
|
|
package http_test
|
|
|
|
|
|
|
|
import (
|
2023-01-14 21:27:37 +00:00
|
|
|
"net/http"
|
2023-01-02 00:11:47 +00:00
|
|
|
"net/http/httptest"
|
2021-11-14 21:15:28 +00:00
|
|
|
"testing"
|
|
|
|
|
2022-03-13 10:58:34 +00:00
|
|
|
delivery "source.toby3d.me/toby3d/auth/internal/health/delivery/http"
|
2024-05-08 11:31:19 +00:00
|
|
|
testutil "source.toby3d.me/toby3d/auth/internal/util/testing"
|
2021-11-14 21:15:28 +00:00
|
|
|
)
|
|
|
|
|
2024-05-08 11:31:19 +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()
|
2023-01-14 21:27:37 +00:00
|
|
|
|
2024-05-08 11:31:19 +00:00
|
|
|
delivery.NewHandler().ServeHTTP(w, req)
|
2021-11-14 21:15:28 +00:00
|
|
|
|
2023-01-02 00:11:47 +00:00
|
|
|
resp := w.Result()
|
2021-11-14 21:15:28 +00:00
|
|
|
|
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)
|
2022-02-01 19:17:22 +00:00
|
|
|
}
|
|
|
|
|
2024-05-08 11:31:19 +00:00
|
|
|
testutil.GoldenEqual(t, resp.Body)
|
2021-11-14 21:15:28 +00:00
|
|
|
}
|