ContainerImage.Pinniped/pkg/handlers/healthz_handler_test.go
Ryan Richard 57a22f99aa Add a simple /healthz endpoint
- Also remove the old hello world code

Signed-off-by: Andrew Keesler <akeesler@vmware.com>
2020-07-06 16:07:21 -07:00

32 lines
760 B
Go

/*
Copyright 2020 VMware, Inc.
SPDX-License-Identifier: Apache-2.0
*/
package handlers_test
import (
"github.com/stretchr/testify/require"
"github.com/suzerain-io/placeholder-name/pkg/handlers"
"io/ioutil"
"net/http"
"net/http/httptest"
"testing"
)
func TestHealthzReturnsOkWithJsonBody(t *testing.T) {
expect := require.New(t)
server := httptest.NewServer(handlers.New())
defer server.Close()
client := http.Client{}
response, err := client.Get(server.URL + "/healthz")
expect.NoError(err)
expect.Equal(http.StatusOK, response.StatusCode)
expect.Equal("application/json; charset=utf-8", response.Header.Get("content-type"))
body, err := ioutil.ReadAll(response.Body)
expect.NoError(err)
expect.JSONEq(`{"status": "OK"}`, string(body))
}