MM-23261 plugin stderr debug logs (#14166)
* explicitly assert panic as error log
* Revert "[MM-18150] plugin panic trace should not be lost (#13559)"
This reverts commit 5d928b4f94, while leaving the unit tests intact
and now asserting debug logs instead.
* missing license header
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
383e45b13d
Коммит
f149ada16a
33
testlib/assertions.go
Обычный файл
33
testlib/assertions.go
Обычный файл
@@ -0,0 +1,33 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
package testlib
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"io"
|
||||
"testing"
|
||||
)
|
||||
|
||||
// AssertLog asserts that a JSON-encoded buffer of logs contains one with the given level and message.
|
||||
func AssertLog(t *testing.T, logs *bytes.Buffer, level, message string) {
|
||||
dec := json.NewDecoder(logs)
|
||||
for {
|
||||
var log struct {
|
||||
Level string
|
||||
Msg string
|
||||
}
|
||||
if err := dec.Decode(&log); err == io.EOF {
|
||||
break
|
||||
} else if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
if log.Level == level && log.Msg == message {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
t.Fatalf("failed to find %s log message: %s", level, message)
|
||||
}
|
||||
Ссылка в новой задаче
Block a user