| 104 | } |
| 105 | |
| 106 | func TestWriteForbidden(t *testing.T) { |
| 107 | ctx := context.TODO() |
| 108 | w := httptest.NewRecorder() |
| 109 | |
| 110 | Forbidden(ctx, w) |
| 111 | |
| 112 | if got, want := w.Code, 403; want != got { |
| 113 | t.Errorf("Want response code %d, got %d", want, got) |
| 114 | } |
| 115 | |
| 116 | errjson := &usererror.Error{} |
| 117 | if err := json.NewDecoder(w.Body).Decode(errjson); err != nil { |
| 118 | t.Error(err) |
| 119 | } |
| 120 | if got, want := errjson.Message, usererror.ErrForbidden.Message; got != want { |
| 121 | t.Errorf("Want error message %s, got %s", want, got) |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | func TestWriteBadRequest(t *testing.T) { |
| 126 | ctx := context.TODO() |