-
Notifications
You must be signed in to change notification settings - Fork 6
/
router_test.go
47 lines (34 loc) · 1006 Bytes
/
router_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 router_test
import (
"testing"
"github.com/hyperledger/fabric-chaincode-go/shim"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/hyperledger-labs/cckit/router"
"github.com/hyperledger-labs/cckit/serialize"
testcc "github.com/hyperledger-labs/cckit/testing"
)
func TestRouter(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Router suite")
}
func New() *router.Chaincode {
r := router.New(`router`, router.WithSerializer(serialize.PreferJSONSerializer)).
Init(router.EmptyContextHandler).
Invoke(`empty`, func(c router.Context) (interface{}, error) {
return nil, nil
})
return router.NewChaincode(r)
}
var cc *testcc.MockStub
var _ = Describe(`Router`, func() {
BeforeSuite(func() {
cc = testcc.NewMockStub(`Router`, New())
})
It(`Allow empty response`, func() {
response := cc.Invoke(`empty`)
Expect(response.Status).To(Equal(int32(shim.OK)))
Expect(response.Payload).To(BeEmpty())
Expect(response.Message).To(BeEmpty())
})
})