Skip to content

Commit

Permalink
add tests for log level transformation
Browse files Browse the repository at this point in the history
  • Loading branch information
vkuptcov committed Oct 4, 2024
1 parent 48c45ab commit 8f3ffe5
Showing 1 changed file with 67 additions and 1 deletion.
68 changes: 67 additions & 1 deletion bridges/otellogrus/hook_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,18 @@ func TestHookFire(t *testing.T) {
},
},
{
name: "emits a log entry with severity level",
name: "emits a log entry with panic severity level",
entry: &logrus.Entry{
Level: logrus.PanicLevel,
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, log.SeverityFatal4, nil),
},
},
},
{
name: "emits a log entry with fatal severity level",
entry: &logrus.Entry{
Level: logrus.FatalLevel,
},
Expand All @@ -188,6 +199,61 @@ func TestHookFire(t *testing.T) {
},
},
},
{
name: "emits a log entry with error severity level",
entry: &logrus.Entry{
Level: logrus.ErrorLevel,
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, log.SeverityError, nil),
},
},
},
{
name: "emits a log entry with warn severity level",
entry: &logrus.Entry{
Level: logrus.WarnLevel,
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, log.SeverityWarn, nil),
},
},
},
{
name: "emits a log entry with info severity level",
entry: &logrus.Entry{
Level: logrus.InfoLevel,
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, log.SeverityInfo, nil),
},
},
},
{
name: "emits a log entry with info severity level",
entry: &logrus.Entry{
Level: logrus.DebugLevel,
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, log.SeverityDebug, nil),
},
},
},
{
name: "emits a log entry with info severity level",
entry: &logrus.Entry{
Level: logrus.TraceLevel,
},
wantRecords: map[string][]log.Record{
name: {
buildRecord(log.StringValue(""), time.Time{}, log.SeverityTrace, nil),
},
},
},
{
name: "emits a log entry with data",
entry: &logrus.Entry{
Expand Down

0 comments on commit 8f3ffe5

Please sign in to comment.