27 lines
558 B
Go
27 lines
558 B
Go
package main
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
)
|
|
|
|
|
|
func TestHealthMessage(t *testing.T) {
|
|
wr := httptest.NewRecorder()
|
|
req := httptest.NewRequest(http.MethodGet, "/health", nil)
|
|
|
|
healthMessage(wr, req)
|
|
if wr.Code != http.StatusOK {
|
|
t.Errorf("got HTTP status code %d, expected 200", wr.Code)
|
|
}
|
|
|
|
if !strings.Contains(wr.Body.String(), `{"health":"OK"}`) {
|
|
t.Errorf(
|
|
`response body "%s" does not contain "health OK"`,
|
|
wr.Body.String(),
|
|
)
|
|
}
|
|
}
|