Skip to content

Commit 036065c

Browse files
authored
Add test for handler context (#45)
I forgot to add this in the previous PR
1 parent 5ffa4ed commit 036065c

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

Diff for: nexus/handler_context_test.go

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package nexus_test
2+
3+
import (
4+
"context"
5+
"testing"
6+
7+
"github.com/nexus-rpc/sdk-go/nexus"
8+
"github.com/stretchr/testify/require"
9+
)
10+
11+
func TestHandlerContext(t *testing.T) {
12+
ctx := nexus.WithHandlerContext(context.Background())
13+
require.True(t, nexus.IsHandlerContext(ctx))
14+
initial := []nexus.Link{{Type: "foo"}, {Type: "bar"}}
15+
nexus.AddHandlerLinks(ctx, initial...)
16+
additional := nexus.Link{Type: "baz"}
17+
nexus.AddHandlerLinks(ctx, additional)
18+
require.Equal(t, append(initial, additional), nexus.HandlerLinks(ctx))
19+
nexus.SetHandlerLinks(ctx, initial...)
20+
require.Equal(t, initial, nexus.HandlerLinks(ctx))
21+
}

0 commit comments

Comments
 (0)