MCPcopy
hub / github.com/grpc/grpc-go / checkLogForSeverity

Function checkLogForSeverity

grpclog/internal/loggerv2_test.go:95–101  ·  view source on GitHub ↗

check if b is in the format of: 2017/04/07 14:55:42 WARNING: WARNING

(s int, b []byte)

Source from the content-addressed store, hash-verified

93//
94// 2017/04/07 14:55:42 WARNING: WARNING
95func checkLogForSeverity(s int, b []byte) error {
96 expected := regexp.MustCompile(fmt.Sprintf(`^[0-9]{4}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2}:[0-9]{2} %s: %s\n$`, severityName[s], severityName[s]))
97 if m := expected.Match(b); !m {
98 return fmt.Errorf("got: %v, want string in format of: %v", string(b), severityName[s]+": 2016/10/05 17:09:26 "+severityName[s])
99 }
100 return nil
101}
102
103func TestLoggerV2Severity(t *testing.T) {
104 buffers := []*bytes.Buffer{new(bytes.Buffer), new(bytes.Buffer), new(bytes.Buffer)}

Callers 1

TestLoggerV2SeverityFunction · 0.85

Calls 2

MatchMethod · 0.65
ErrorfMethod · 0.65

Tested by

no test coverage detected