30 lines
640 B
Go
30 lines
640 B
Go
package http_test
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
delivery "source.toby3d.me/toby3d/auth/internal/health/delivery/http"
|
|
testutil "source.toby3d.me/toby3d/auth/internal/util/testing"
|
|
)
|
|
|
|
func TestHandler_ServeHTTP(t *testing.T) {
|
|
t.Parallel()
|
|
|
|
req := httptest.NewRequest(http.MethodGet, "https://example.com/health", nil)
|
|
w := httptest.NewRecorder()
|
|
|
|
h := delivery.NewHandler()
|
|
h.Test = true
|
|
|
|
h.ServeHTTP(w, req)
|
|
|
|
resp := w.Result()
|
|
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)
|
|
}
|