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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
package raven
import (
"context"
"reflect"
"testing"
raven "github.com/getsentry/raven-go"
"gitlab.com/gitlab-org/labkit/correlation"
)
func TestSetExtra(t *testing.T) {
tests := []struct {
name string
ctx context.Context
extra raven.Extra
want raven.Extra
}{
{
name: "context",
ctx: correlation.ContextWithCorrelation(context.Background(), "C001"),
extra: map[string]interface{}{
"key": "value",
},
want: map[string]interface{}{
"key": "value",
ravenSentryExtraKey: "C001",
},
},
{
name: "no_injected_extras",
ctx: correlation.ContextWithCorrelation(context.Background(), "C001"),
extra: nil,
want: map[string]interface{}{
ravenSentryExtraKey: "C001",
},
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := SetExtra(tt.ctx, tt.extra); !reflect.DeepEqual(got, tt.want) {
t.Errorf("SetExtra() = %v, want %v", got, tt.want)
}
})
}
}
|