forked from dapr/go-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbinding_test.go
45 lines (37 loc) · 1.01 KB
/
binding_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
package client
import (
"context"
"testing"
"github.com/stretchr/testify/assert"
)
// go test -timeout 30s ./client -count 1 -run ^TestInvokeBinding$
func TestInvokeBinding(t *testing.T) {
ctx := context.Background()
in := &InvokeBindingRequest{
Name: "test",
Operation: "fn",
}
t.Run("output binding without data", func(t *testing.T) {
err := testClient.InvokeOutputBinding(ctx, in)
assert.Nil(t, err)
})
t.Run("output binding", func(t *testing.T) {
in.Data = []byte("test")
err := testClient.InvokeOutputBinding(ctx, in)
assert.Nil(t, err)
})
t.Run("binding without data", func(t *testing.T) {
in.Data = nil
out, err := testClient.InvokeBinding(ctx, in)
assert.Nil(t, err)
assert.NotNil(t, out)
})
t.Run("binding with data and meta", func(t *testing.T) {
in.Data = []byte("test")
in.Metadata = map[string]string{"k1": "v1", "k2": "v2"}
out, err := testClient.InvokeBinding(ctx, in)
assert.Nil(t, err)
assert.NotNil(t, out)
assert.Equal(t, "test", string(out.Data))
})
}