health: basic health checker from the monitor
This commit is contained in:
27
health/health_test.go
Normal file
27
health/health_test.go
Normal file
@@ -0,0 +1,27 @@
|
||||
package health
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestHealthHandler(t *testing.T) {
|
||||
|
||||
req := httptest.NewRequest(http.MethodGet, "/__health", nil)
|
||||
w := httptest.NewRecorder()
|
||||
|
||||
basicHealth(w, req)
|
||||
|
||||
res := w.Result()
|
||||
defer res.Body.Close()
|
||||
data, err := io.ReadAll(res.Body)
|
||||
if err != nil {
|
||||
t.Errorf("expected error to be nil got %v", err)
|
||||
}
|
||||
if string(data) != "ok" {
|
||||
t.Fail()
|
||||
t.Errorf("expected ok got %q", string(data))
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user