MCPcopy
hub / github.com/sourcegraph/checkup / TestResultStatus

Function TestResultStatus

checkup_test.go:111–146  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

109}
110
111func TestResultStatus(t *testing.T) {
112 r := types.Result{Healthy: true}
113 if got, want := r.Status(), types.StatusHealthy; got != want {
114 t.Errorf("Expected status '%s' but got: '%s'", want, got)
115 }
116
117 r = types.Result{Degraded: true}
118 if got, want := r.Status(), types.StatusDegraded; got != want {
119 t.Errorf("Expected status '%s' but got: '%s'", want, got)
120 }
121
122 r = types.Result{Down: true}
123 if got, want := r.Status(), types.StatusDown; got != want {
124 t.Errorf("Expected status '%s' but got: '%s'", want, got)
125 }
126
127 r = types.Result{}
128 if got, want := r.Status(), types.StatusUnknown; got != want {
129 t.Errorf("Expected status '%s' but got: '%s'", want, got)
130 }
131
132 // These are invalid states, but we need to test anyway in case a
133 // checker is buggy. We expect the worst of the enabled fields.
134 r = types.Result{Down: true, Degraded: true}
135 if got, want := r.Status(), types.StatusDown; got != want {
136 t.Errorf("(INVALID RESULT CASE) Expected status '%s' but got: '%s'", want, got)
137 }
138 r = types.Result{Degraded: true, Healthy: true}
139 if got, want := r.Status(), types.StatusDegraded; got != want {
140 t.Errorf("(INVALID RESULT CASE) Expected status '%s' but got: '%s'", want, got)
141 }
142 r = types.Result{Down: true, Healthy: true}
143 if got, want := r.Status(), types.StatusDown; got != want {
144 t.Errorf("(INVALID RESULT CASE) Expected status '%s' but got: '%s'", want, got)
145 }
146}
147
148func TestPriorityOver(t *testing.T) {
149 for i, test := range []struct {

Callers

nothing calls this directly

Calls 1

StatusMethod · 0.95

Tested by

no test coverage detected