From 85c9baf5f4748e0d81651cbc365fc80724707bb9 Mon Sep 17 00:00:00 2001 From: Dimitar Petrov Date: Tue, 25 Jun 2019 12:41:08 +0300 Subject: [PATCH] Minor tweaks --- api/healthcheck/healthcheck_controller.go | 2 +- pkg/health/registry_test.go | 2 -- pkg/health/settings_test.go | 12 ++++++++++++ pkg/health/types.go | 18 ------------------ 4 files changed, 13 insertions(+), 21 deletions(-) diff --git a/api/healthcheck/healthcheck_controller.go b/api/healthcheck/healthcheck_controller.go index 0d10c134f..95f4975a7 100644 --- a/api/healthcheck/healthcheck_controller.go +++ b/api/healthcheck/healthcheck_controller.go @@ -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 { diff --git a/pkg/health/registry_test.go b/pkg/health/registry_test.go index cd38ad351..f8c98da6a 100644 --- a/pkg/health/registry_test.go +++ b/pkg/health/registry_test.go @@ -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) diff --git a/pkg/health/settings_test.go b/pkg/health/settings_test.go index f40b3f930..4436f3d90 100644 --- a/pkg/health/settings_test.go +++ b/pkg/health/settings_test.go @@ -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()) + }) + }) }) diff --git a/pkg/health/types.go b/pkg/health/types.go index 4f8c451de..54c105fe4 100644 --- a/pkg/health/types.go +++ b/pkg/health/types.go @@ -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 {