Skip to content

Commit

Permalink
Minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
DimitarPetrov committed Jun 25, 2019
1 parent acca7c0 commit 85c9baf
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 21 deletions.
2 changes: 1 addition & 1 deletion api/healthcheck/healthcheck_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (c *controller) healthCheck(r *web.Request) (*web.Response, error) {

func (c *controller) aggregate(state map[string]h.State) *health.Health {
if len(state) == 0 {
return health.New().WithDetail("error", "no health indicators registered").Unknown()
return health.New().WithDetail("error", "no health indicators registered")
}
overallStatus := health.StatusUp
for i, v := range state {
Expand Down
2 changes: 0 additions & 2 deletions pkg/health/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@ var _ = Describe("Healthcheck Registry", func() {
Expect(newIndicator.Interval()).To(Equal(DefaultIndicatorSettings().Interval))
Expect(newIndicator.FailuresTreshold()).To(Equal(DefaultIndicatorSettings().FailuresTreshold))
})
})

When("When configure indicators", func() {
It("Should configure with provided settings", func() {
newIndicator := &testIndicator{}
registry.HealthIndicators = append(registry.HealthIndicators, newIndicator)
Expand Down
12 changes: 12 additions & 0 deletions pkg/health/settings_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,16 @@ var _ = Describe("Healthcheck Settings", func() {
assertValidationErrorOccured(err)
})
})

When("Indicator with positive treshold and interval > 30", func() {
It("Should be considered valid", func() {
interval = 30
failuresTreshold = 3
registerIndicatorSettings()

err := settings.Validate()

Expect(err).ShouldNot(HaveOccurred())
})
})
})
18 changes: 0 additions & 18 deletions pkg/health/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,24 +127,6 @@ func (h *Health) WithDetail(key string, val interface{}) *Health {
return h
}

// Up sets the health status to up
func (h *Health) Up() *Health {
h.Status = StatusUp
return h
}

// Down sets the health status to down
func (h *Health) Down() *Health {
h.Status = StatusDown
return h
}

// Unknown sets the health status to unknown
func (h *Health) Unknown() *Health {
h.Status = StatusUnknown
return h
}

// WithDetails adds the given details to the health
func (h *Health) WithDetails(details map[string]interface{}) *Health {
for k, v := range details {
Expand Down

0 comments on commit 85c9baf

Please sign in to comment.