| 109 | } |
| 110 | |
| 111 | func 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 | |
| 148 | func TestPriorityOver(t *testing.T) { |
| 149 | for i, test := range []struct { |