MCPcopy
hub / github.com/harness/harness / TestWriteErrorCode

Function TestWriteErrorCode

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

Source from the content-addressed store, hash-verified

47}
48
49func TestWriteErrorCode(t *testing.T) {
50 ctx := context.TODO()
51 w := httptest.NewRecorder()
52
53 UserError(ctx, w, usererror.Newf(418, "pc load letter %d", 1))
54
55 if got, want := w.Code, 418; want != got {
56 t.Errorf("Want response code %d, got %d", want, got)
57 }
58
59 errjson := &usererror.Error{}
60 if err := json.NewDecoder(w.Body).Decode(errjson); err != nil {
61 t.Error(err)
62 }
63 if got, want := errjson.Message, "pc load letter 1"; got != want {
64 t.Errorf("Want error message %s, got %s", want, got)
65 }
66}
67
68func TestWriteNotFound(t *testing.T) {
69 ctx := context.TODO()

Callers

nothing calls this directly

Calls 5

NewfFunction · 0.92
UserErrorFunction · 0.85
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…