Skip to content

Commit b6a29a5

Browse files
author
Aaron Schlesinger
committed
fix(pkg/healthsrv/healthz_handler_test.go): adding success case test
1 parent 4f1d853 commit b6a29a5

1 file changed

Lines changed: 16 additions & 1 deletion

File tree

pkg/healthsrv/healthz_handler_test.go

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package healthsrv
22

33
import (
44
"bytes"
5+
"encoding/json"
56
"errors"
67
"fmt"
78
"net/http"
@@ -65,5 +66,19 @@ func TestHealthZNamespaceListErr(t *testing.T) {
6566
}
6667

6768
func TestHealthZSuccess(t *testing.T) {
68-
t.Skip("TODO")
69+
nsLister := emptyNamespaceLister{}
70+
bLister := emptyBucketLister{}
71+
c := sshd.NewCircuit()
72+
c.Close()
73+
74+
h := healthZHandler(nsLister, bLister, c)
75+
w := httptest.NewRecorder()
76+
r, err := http.NewRequest("GET", "/healthz", bytes.NewBuffer(nil))
77+
assert.NoErr(t, err)
78+
h.ServeHTTP(w, r)
79+
assert.Equal(t, w.Code, http.StatusOK, "response code")
80+
expectedResp := healthZResp{Namespaces: nil, S3Buckets: nil, SSHServerStarted: true}
81+
var expectedRespBytes bytes.Buffer
82+
assert.NoErr(t, json.NewEncoder(&expectedRespBytes).Encode(expectedResp))
83+
assert.Equal(t, string(w.Body.Bytes()), string(expectedRespBytes.Bytes()), "response body")
6984
}

0 commit comments

Comments
 (0)