Skip to content

Commit

Permalink
fix(pkg/healthsrv/healthz_handler_test.go): adding success case test
Browse files Browse the repository at this point in the history
  • Loading branch information
Aaron Schlesinger committed Feb 9, 2016
1 parent 4b9fbd7 commit 1b58590
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion pkg/healthsrv/healthz_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package healthsrv

import (
"bytes"
"encoding/json"
"errors"
"fmt"
"net/http"
Expand Down Expand Up @@ -65,5 +66,19 @@ func TestHealthZNamespaceListErr(t *testing.T) {
}

func TestHealthZSuccess(t *testing.T) {
t.Skip("TODO")
nsLister := emptyNamespaceLister{}
bLister := emptyBucketLister{}
c := sshd.NewCircuit()
c.Close()

h := healthZHandler(nsLister, bLister, c)
w := httptest.NewRecorder()
r, err := http.NewRequest("GET", "/healthz", bytes.NewBuffer(nil))
assert.NoErr(t, err)
h.ServeHTTP(w, r)
assert.Equal(t, w.Code, http.StatusOK, "response code")
expectedResp := healthZResp{Namespaces: nil, S3Buckets: nil, SSHServerStarted: true}
var expectedRespBytes bytes.Buffer
assert.NoErr(t, json.NewEncoder(&expectedRespBytes).Encode(expectedResp))
assert.Equal(t, string(w.Body.Bytes()), string(expectedRespBytes.Bytes()), "response body")
}

0 comments on commit 1b58590

Please sign in to comment.