~dstroppa/juju-core/joyent-provider-storage

« back to all changes in this revision

Viewing changes to rpc/rpc_test.go

  • Committer: Daniele Stroppa
  • Date: 2014-01-08 15:58:10 UTC
  • mfrom: (1953.1.231 juju-core)
  • Revision ID: daniele.stroppa@joyent.com-20140108155810-xecbwrqkb5i0fyoe
Merging trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
678
678
        testBadCall(c, client, clientNotifier, serverNotifier,
679
679
                rpc.Request{"BadSomething", "a0", "No"},
680
680
                `unknown object type "BadSomething"`,
 
681
                rpc.CodeNotImplemented,
681
682
                false,
682
683
        )
683
684
        testBadCall(c, client, clientNotifier, serverNotifier,
684
685
                rpc.Request{"SimpleMethods", "xx", "No"},
685
 
                `no such request "No" on SimpleMethods`,
 
686
                "no such request - method SimpleMethods.No is not implemented",
 
687
                rpc.CodeNotImplemented,
686
688
                false,
687
689
        )
688
690
        testBadCall(c, client, clientNotifier, serverNotifier,
689
691
                rpc.Request{"SimpleMethods", "xx", "Call0r0"},
690
692
                `unknown SimpleMethods id`,
 
693
                "",
691
694
                true,
692
695
        )
693
696
}
698
701
        clientNotifier, serverNotifier *notifier,
699
702
        req rpc.Request,
700
703
        expectedErr string,
 
704
        expectedErrCode string,
701
705
        requestKnown bool,
702
706
) {
703
707
        clientNotifier.reset()
704
708
        serverNotifier.reset()
705
709
        err := client.Call(req, nil, nil)
706
 
        c.Assert(err, gc.ErrorMatches, regexp.QuoteMeta("request error: "+expectedErr))
 
710
        msg := expectedErr
 
711
        if expectedErrCode != "" {
 
712
                msg += " (" + expectedErrCode + ")"
 
713
        }
 
714
        c.Assert(err, gc.ErrorMatches, regexp.QuoteMeta("request error: "+msg))
707
715
 
708
716
        // Test that there was a notification for the client request.
709
717
        c.Assert(clientNotifier.clientRequests, gc.HasLen, 1)
724
732
                hdr: rpc.Header{
725
733
                        RequestId: requestId,
726
734
                        Error:     expectedErr,
 
735
                        ErrorCode: expectedErrCode,
727
736
                },
728
737
        })
729
738
 
753
762
                hdr: rpc.Header{
754
763
                        RequestId: requestId,
755
764
                        Error:     expectedErr,
 
765
                        ErrorCode: expectedErrCode,
756
766
                },
757
767
                req:  req,
758
768
                body: struct{}{},
856
866
        defer closeClient(c, client, srvDone)
857
867
        var s stringVal
858
868
        err := client.Call(rpc.Request{"NewlyAvailable", "", "NewMethod"}, nil, &s)
859
 
        c.Assert(err, gc.ErrorMatches, `request error: unknown object type "NewlyAvailable"`)
 
869
        c.Assert(err, gc.ErrorMatches, `request error: unknown object type "NewlyAvailable" \(not implemented\)`)
860
870
        err = client.Call(rpc.Request{"ChangeAPIMethods", "", "ChangeAPI"}, nil, nil)
861
871
        c.Assert(err, gc.IsNil)
862
872
        err = client.Call(rpc.Request{"ChangeAPIMethods", "", "ChangeAPI"}, nil, nil)
863
 
        c.Assert(err, gc.ErrorMatches, `request error: unknown object type "ChangeAPIMethods"`)
 
873
        c.Assert(err, gc.ErrorMatches, `request error: unknown object type "ChangeAPIMethods" \(not implemented\)`)
864
874
        err = client.Call(rpc.Request{"NewlyAvailable", "", "NewMethod"}, nil, &s)
865
875
        c.Assert(err, gc.IsNil)
866
876
        c.Assert(s, gc.Equals, stringVal{"new method result"})