(t *testing.T)
| 85 | } |
| 86 | |
| 87 | func TestWriteUnauthorized(t *testing.T) { |
| 88 | ctx := context.TODO() |
| 89 | w := httptest.NewRecorder() |
| 90 | |
| 91 | Unauthorized(ctx, w) |
| 92 | |
| 93 | if got, want := w.Code, 401; want != got { |
| 94 | t.Errorf("Want response code %d, got %d", want, got) |
| 95 | } |
| 96 | |
| 97 | errjson := &usererror.Error{} |
| 98 | if err := json.NewDecoder(w.Body).Decode(errjson); err != nil { |
| 99 | t.Error(err) |
| 100 | } |
| 101 | if got, want := errjson.Message, usererror.ErrUnauthorized.Message; got != want { |
| 102 | t.Errorf("Want error message %s, got %s", want, got) |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | func TestWriteForbidden(t *testing.T) { |
| 107 | ctx := context.TODO() |
nothing calls this directly
no test coverage detected
searching dependent graphs…