Commit 61dd6644 authored by Michelle Noorali's avatar Michelle Noorali

ref(manager): add /healthz body/content-type test

parent 8c55a6ef
...@@ -3,7 +3,9 @@ package main ...@@ -3,7 +3,9 @@ package main
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"io/ioutil"
"net/http" "net/http"
"strings"
"testing" "testing"
"github.com/kubernetes/helm/pkg/common" "github.com/kubernetes/helm/pkg/common"
...@@ -15,13 +17,29 @@ func TestHealthz(t *testing.T) { ...@@ -15,13 +17,29 @@ func TestHealthz(t *testing.T) {
defer s.Close() defer s.Close()
res, err := http.Get(s.URL) res, err := http.Get(s.URL)
if err != nil {
t.Fatalf("err on http get: %v", err)
}
body, err := ioutil.ReadAll(res.Body)
defer res.Body.Close()
if err != nil { if err != nil {
t.Fatalf("Failed to GET healthz: %s", err) t.Fatalf("Failed to GET healthz: %s", err)
} else if res.StatusCode != 200 { } else if res.StatusCode != 200 {
t.Fatalf("Unexpected status: %d", res.StatusCode) t.Fatalf("Unexpected status: %d", res.StatusCode)
} }
// TODO: Get the body and check on the content type and the body. expectedBody := "OK"
if bytes.Equal(body, []byte(expectedBody)) {
t.Fatalf("Expected response body: %s, Actual response body: %s",
expectedBody, string(body))
}
expectedContentType := "text/plain"
contentType := res.Header["Content-Type"][0]
if !strings.Contains(contentType, expectedContentType) {
t.Fatalf("Expected Content-Type to include %s", expectedContentType)
}
} }
func TestCreateDeployments(t *testing.T) { func TestCreateDeployments(t *testing.T) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment