-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontext_test.go
47 lines (43 loc) · 886 Bytes
/
context_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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package amqp091otel
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
"github.com/rabbitmq/amqp091-go"
)
func TestContextFromDelivery(t *testing.T) {
t.Parallel()
type key struct{}
ctxInst := context.WithValue(context.Background(), key{}, "value")
type args struct {
msg amqp091.Delivery
}
tests := []struct {
name string
args args
want context.Context
}{
{
name: "instrumented context",
args: args{
msg: amqp091.Delivery{
Acknowledger: &acknowledger{ctx: ctxInst},
},
},
want: ctxInst,
}, {
name: "background context",
args: args{
msg: amqp091.Delivery{},
},
want: context.Background(),
},
}
for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) {
t.Parallel()
assert.Equalf(t, tt.want, ContextFromDelivery(tt.args.msg), "ContextFromDelivery(%v)", tt.args.msg)
})
}
}