Fix Sentry Debug Regex

that was ignoring composed messages including a newline.
Also, add regression test.
This commit is contained in:
Maximilian Paß
2023-03-11 13:19:55 +00:00
committed by Sebastian Serth
parent 6e069f5d8a
commit e0419c2e58
3 changed files with 30 additions and 11 deletions

View File

@ -21,6 +21,18 @@ func TestSentryDebugWriter_Write(t *testing.T) {
assert.NotContains(t, buf.String(), description)
}
func TestSentryDebugWriter_WriteComposed(t *testing.T) {
buf := &bytes.Buffer{}
w := SentryDebugWriter{Target: buf, Ctx: context.Background()}
data := "Hello World!\r\n\x1EPoseidon unset 1678540012404\x1E\x1EPoseidon /sbin/setuser user 1678540012408\x1E"
count, err := w.Write([]byte(data))
require.NoError(t, err)
assert.Equal(t, len(data), count)
assert.Contains(t, buf.String(), "Hello World!")
}
func TestSentryDebugWriter_Close(t *testing.T) {
buf := &bytes.Buffer{}
s := NewSentryDebugWriter(buf, context.Background())