Skip to content

Commit

Permalink
fix: imports
Browse files Browse the repository at this point in the history
  • Loading branch information
acha-bill committed Sep 11, 2024
1 parent 1ab0eef commit 9c43612
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 18 deletions.
18 changes: 8 additions & 10 deletions pkg/api/readiness.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,24 @@ package api
import (
"net/http"

"github.com/ethersphere/bee"
"github.com/ethersphere/bee/pkg/jsonhttp"
"github.com/ethersphere/bee/v2"
"github.com/ethersphere/bee/v2/pkg/jsonhttp"
)

type ReadyStatusResponse healthStatusResponse

func (s *Service) readinessHandler(w http.ResponseWriter, _ *http.Request) {
if s.probe.Ready() == ProbeStatusOK {
jsonhttp.OK(w, ReadyStatusResponse{
Status: "ready",
Version: bee.Version,
APIVersion: Version,
DebugAPIVersion: DebugVersion,
Status: "ready",
Version: bee.Version,
APIVersion: Version,
})
} else {
jsonhttp.BadRequest(w, ReadyStatusResponse{
Status: "notReady",
Version: bee.Version,
APIVersion: Version,
DebugAPIVersion: DebugVersion,
Status: "notReady",
Version: bee.Version,
APIVersion: Version,
})
}
}
14 changes: 6 additions & 8 deletions pkg/api/readiness_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,20 +39,18 @@ func TestReadiness(t *testing.T) {
probe.SetReady(api.ProbeStatusOK)
jsonhttptest.Request(t, testServer, http.MethodGet, "/readiness", http.StatusOK,
jsonhttptest.WithExpectedJSONResponse(api.ReadyStatusResponse{
Status: "ready",
Version: "-dev",
APIVersion: "0.0.0",
DebugAPIVersion: "0.0.0",
Status: "ready",
Version: "-dev",
APIVersion: "0.0.0",
}))

// When we set readiness probe to NOK it should indicate that API is not ready
probe.SetReady(api.ProbeStatusNOK)
jsonhttptest.Request(t, testServer, http.MethodGet, "/readiness", http.StatusBadRequest,
jsonhttptest.WithExpectedJSONResponse(api.ReadyStatusResponse{
Status: "notReady",
Version: "-dev",
APIVersion: "0.0.0",
DebugAPIVersion: "0.0.0",
Status: "notReady",
Version: "-dev",
APIVersion: "0.0.0",
}))
})
}

0 comments on commit 9c43612

Please sign in to comment.