Skip to content

Commit

Permalink
remove superfluous checks in unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
rubvs committed Aug 29, 2024
1 parent 066a706 commit 1b5ee67
Showing 1 changed file with 7 additions and 19 deletions.
26 changes: 7 additions & 19 deletions model/modelprocessor/errormessage_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ import (

func TestSetEventMessage(t *testing.T) {
tests := []struct {
desc string
input *modelpb.APMEvent
expectedMessage string
expectedLogMessage string
expectedExceptionMessage string
desc string
input *modelpb.APMEvent
expectedMessage string
}{{
desc: "keep event message when no error",
input: &modelpb.APMEvent{
Expand All @@ -43,9 +41,7 @@ func TestSetEventMessage(t *testing.T) {
},
Message: "message",
},
expectedMessage: "message",
expectedLogMessage: "",
expectedExceptionMessage: "",
expectedMessage: "message",
}, {
desc: "keep event message when error",
input: &modelpb.APMEvent{
Expand All @@ -55,9 +51,7 @@ func TestSetEventMessage(t *testing.T) {
},
Message: "message",
},
expectedMessage: "message",
expectedLogMessage: "log_message",
expectedExceptionMessage: "exception_message",
expectedMessage: "message",
}, {
desc: "propagate log error if event message empty",
input: &modelpb.APMEvent{
Expand All @@ -67,9 +61,7 @@ func TestSetEventMessage(t *testing.T) {
},
Message: "",
},
expectedMessage: "log_message",
expectedLogMessage: "log_message",
expectedExceptionMessage: "",
expectedMessage: "log_message",
}, {
desc: "propagate exception error if event message is empty",
input: &modelpb.APMEvent{
Expand All @@ -79,9 +71,7 @@ func TestSetEventMessage(t *testing.T) {
},
Message: "",
},
expectedMessage: "exception_message",
expectedLogMessage: "",
expectedExceptionMessage: "exception_message",
expectedMessage: "exception_message",
}}

for _, test := range tests {
Expand All @@ -90,7 +80,5 @@ func TestSetEventMessage(t *testing.T) {
err := processor.ProcessBatch(context.Background(), &batch)
assert.NoError(t, err)
assert.Equal(t, test.expectedMessage, batch[0].Message)
assert.Equal(t, test.expectedLogMessage, batch[0].Error.Log.Message)
assert.Equal(t, test.expectedExceptionMessage, batch[0].Error.Exception.Message)
}
}

0 comments on commit 1b5ee67

Please sign in to comment.