MCPcopy Create free account
hub / github.com/chain/Core / TestLogSkip

Function TestLogSkip

net/http/httperror/httperror_test.go:53–75  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

51}
52
53func TestLogSkip(t *testing.T) {
54 var buf bytes.Buffer
55 log.SetOutput(&buf)
56
57 formatter := Formatter{
58 Default: Info{500, "CH000", "Internal server error"},
59 IsTemporary: func(Info, error) bool { return false },
60 Errors: map[error]Info{},
61 }
62 formatter.Log(context.Background(), errors.New("an unmapped error"))
63
64 logStr := string(buf.Bytes())
65 if len(logStr) == 0 {
66 t.Error("expected error to be logged")
67 }
68 if strings.Contains(logStr, "at=httperror.go") {
69 t.Errorf("expected httperror stack frames to be skipped but got:\n%s", logStr)
70 }
71 if !strings.Contains(logStr, "status=500") {
72 t.Errorf("expected status code of default error info but got:\n%s", logStr)
73 }
74 t.Log(logStr)
75}

Callers

nothing calls this directly

Calls 4

LogMethod · 0.95
ContainsMethod · 0.80
BytesMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected