MCPcopy
hub / github.com/grafana/tempo / TestRunHealthCheck

Function TestRunHealthCheck

cmd/tempo/health_test.go:12–34  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

10)
11
12func TestRunHealthCheck(t *testing.T) {
13 tests := []struct {
14 name string
15 statusCode int
16 body string
17 wantExit int
18 }{
19 {"healthy", http.StatusOK, "", 0},
20 {"unhealthy", http.StatusServiceUnavailable, "not ready", 1},
21 }
22
23 for _, tt := range tests {
24 t.Run(tt.name, func(t *testing.T) {
25 server := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, _ *http.Request) {
26 w.WriteHeader(tt.statusCode)
27 fmt.Fprint(w, tt.body)
28 }))
29 defer server.Close()
30
31 assert.Equal(t, tt.wantExit, RunHealthCheck(server.URL+"/ready"))
32 })
33 }
34}
35
36func TestRunHealthCheckDefaultURL(t *testing.T) {
37 assert.Equal(t, 1, RunHealthCheck(""))

Callers

nothing calls this directly

Calls 5

RunHealthCheckFunction · 0.85
CloseMethod · 0.65
RunMethod · 0.45
WriteHeaderMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected