Skip to content

Commit

Permalink
add test for duplicated notify calls
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-hontarau committed Jan 30, 2025
1 parent fe263c2 commit fdfa2f4
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package spcontext_test
import (
"bytes"
"context"
"github.com/stretchr/testify/assert"
"testing"

"github.com/bugsnag/bugsnag-go/v2"
Expand Down Expand Up @@ -309,3 +310,23 @@ func TestBackgroundWithValuesFrom(t *testing.T) {
require.Equal(t, "keyValue", backgroundWithValues.Value("keyName"))
require.Equal(t, "fieldValue", backgroundWithValues.Fields().Value("fieldName"))
}

func TestNotifiedLogic(t *testing.T) {
base := spcontext.New(log.NewNopLogger())
notifier := new(testutils.MockNotifier)
notifier.On(
"Notify",
mock.MatchedBy(func(in interface{}) bool {
err, ok := in.(error)
require.True(t, ok)
assert.EqualError(t, err, "initial error")
return true
}),
mock.Anything,
).Times(1).Return(nil)
defer notifier.AssertExpectations(t)
base.Notifier = notifier
err := base.InternalError(errors.New("initial error"), "foo")
err = base.DirectError(err, "skipped error")
err = base.DirectError(err, "also skipped error")
}

0 comments on commit fdfa2f4

Please sign in to comment.