forked from actatum/stormrpc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontext_test.go
47 lines (44 loc) · 922 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 stormrpc provides the functionality for creating RPC servers/clients that communicate via NATS.
package stormrpc
import (
"context"
"reflect"
"testing"
"github.com/nats-io/nats.go"
)
func TestHeadersFromContext(t *testing.T) {
type args struct {
ctx context.Context
}
tests := []struct {
name string
args args
want nats.Header
}{
{
name: "ok",
args: args{
ctx: newContextWithHeaders(context.Background(), nats.Header{
"name": []string{"Gon Freecs"},
}),
},
want: nats.Header{
"name": []string{"Gon Freecs"},
},
},
{
name: "no headers",
args: args{
ctx: context.Background(),
},
want: make(nats.Header),
},
}
for _, tt := range tests {
t.Run(tt.name, func(t *testing.T) {
if got := HeadersFromContext(tt.args.ctx); !reflect.DeepEqual(got, tt.want) {
t.Errorf("HeadersFromContext() = %v, want %v", got, tt.want)
}
})
}
}