23 lines
569 B
Go
23 lines
569 B
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
func TestHealthRouteIdentifiesBell(t *testing.T) {
|
|
gin.SetMode(gin.TestMode)
|
|
router := gin.New()
|
|
registerHealthRoute(router)
|
|
recorder := httptest.NewRecorder()
|
|
request := httptest.NewRequest(http.MethodGet, "/healthz", nil)
|
|
router.ServeHTTP(recorder, request)
|
|
if recorder.Code != http.StatusOK || !strings.Contains(recorder.Body.String(), `"service":"bell"`) {
|
|
t.Fatalf("unexpected health response: %d %s", recorder.Code, recorder.Body.String())
|
|
}
|
|
}
|