-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
logger_test.go
30 lines (25 loc) · 966 Bytes
/
logger_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package profiler
import (
"testing"
"github.com/rs/zerolog"
"github.com/stretchr/testify/require"
)
func TestDataDogLoggerBridge(t *testing.T) {
tests := []struct {
expectedLevel zerolog.Level
expectedMessage string
log string
}{
{zerolog.NoLevel, "", "foo"},
{zerolog.NoLevel, "", "Datadog Tracer v1.55.0 TRACE: Oops!"},
{zerolog.DebugLevel, "Oops!", "Datadog Tracer v1.55.0 DEBUG: Oops!"},
{zerolog.InfoLevel, "foo", "Datadog Tracer v1.0.0 INFO: foo"},
{zerolog.WarnLevel, "ouch!", "Datadog Tracer 1.0 WARN: ouch!"},
{zerolog.ErrorLevel, "Uploading profile failed: 500 Internal Server Error. Trying again in 19.976665696s...", "Datadog Tracer v1.55.0 ERROR: Uploading profile failed: 500 Internal Server Error. Trying again in 19.976665696s..."},
}
for _, test := range tests {
level, message := parseDDLog(test.log)
require.Equal(t, test.expectedLevel, level)
require.Equal(t, test.expectedMessage, message)
}
}