Skip to content
This repository has been archived by the owner on Mar 15, 2022. It is now read-only.

Commit

Permalink
Add test coverage for customer live / ready paths
Browse files Browse the repository at this point in the history
  • Loading branch information
krak3n committed Mar 19, 2019
1 parent 51af758 commit 1993a41
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a h1:BtpsbiV638WQZwhA98cEZw2BsbnQJrbd0BI7tsy0W1c=
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/golang/protobuf v1.0.0 h1:lsek0oXi8iFE9L+EXARyHIjU5rlWIhhTkjDz3vHhWWQ=
github.com/golang/protobuf v1.0.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U=
github.com/matttproud/golang_protobuf_extensions v1.0.0 h1:YNOwxxSJzSUARoD9KRZLzM9Y858MNGCOACTvCW9TSAc=
github.com/matttproud/golang_protobuf_extensions v1.0.0/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/prometheus/client_golang v0.0.0-20180223144718-c3324c1198cf h1:YtiXRsgYGXlAj+EHLMjLfsk5jrMpY/E3nmhIyUijV4E=
github.com/prometheus/client_golang v0.0.0-20180223144718-c3324c1198cf/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
Expand All @@ -14,5 +16,7 @@ github.com/prometheus/common v0.0.0-20180228092548-6fb6fce6f8b7 h1:M7FNIWkkGyntt
github.com/prometheus/common v0.0.0-20180228092548-6fb6fce6f8b7/go.mod h1:daVV7qP5qjZbuso7PdcryaAu0sAZbrN9i7WWcTMWvro=
github.com/prometheus/procfs v0.0.0-20180306113821-7186fbf4eb22 h1:jDQlbutSgD69Ul07voXv2yCaFilf4/jjNoUhmOIrR1k=
github.com/prometheus/procfs v0.0.0-20180306113821-7186fbf4eb22/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk=
github.com/stretchr/testify v1.2.1 h1:52QO5WkIUcHGIR7EnGagH88x1bUzqGXTC5/1bDTUQ7U=
github.com/stretchr/testify v1.2.1/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 h1:FVCohIoYO7IJoDDVpV2pdq7SgrMH6wHnuTyrdrxJNoY=
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0/go.mod h1:OdE7CF6DbADk7lN8LIKRzRJTTZXIjtWgA5THM5lhBAw=
24 changes: 24 additions & 0 deletions handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ func TestNewHandler(t *testing.T) {
name string
method string
path string
opts []HandlerOption
live bool
ready bool
expect int
Expand Down Expand Up @@ -120,10 +121,33 @@ func TestNewHandler(t *testing.T) {
expect: http.StatusServiceUnavailable,
expectBody: "{}\n",
},
{
name: "with custom live path should succeed",
method: "GET",
path: "/_live",
opts: []HandlerOption{WithLivenessPath("/_live")},
live: true,
ready: true,
expect: http.StatusOK,
expectBody: "{}\n",
},
{
name: "with custom ready path should succeed",
method: "GET",
path: "/_readiness",
opts: []HandlerOption{WithLivenessPath("/_readiness")},
live: true,
ready: true,
expect: http.StatusOK,
expectBody: "{}\n",
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
h := NewHandler()
if tt.opts != nil {
h = NewHandler(tt.opts...)
}

if !tt.live {
h.AddLivenessCheck("test-liveness-check", func() error {
Expand Down

0 comments on commit 1993a41

Please sign in to comment.