MCPcopy
hub / github.com/harness/harness / TestWriteForbidden

Function TestWriteForbidden

app/api/render/render_test.go:106–123  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

104}
105
106func 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
125func TestWriteBadRequest(t *testing.T) {
126 ctx := context.TODO()

Callers

nothing calls this directly

Calls 4

ForbiddenFunction · 0.70
DecodeMethod · 0.65
ErrorMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…