Documentation ¶
Index ¶
- Constants
- type GDS
- func (g *GDS) Client() (client gds.TRISADirectoryClient, err error)
- func (g *GDS) DialOpts() (opts []grpc.DialOption)
- func (g *GDS) Lookup(ctx context.Context, in *gds.LookupRequest) (*gds.LookupReply, error)
- func (g *GDS) Register(ctx context.Context, in *gds.RegisterRequest) (*gds.RegisterReply, error)
- func (g *GDS) Reset()
- func (g *GDS) Search(ctx context.Context, in *gds.SearchRequest) (*gds.SearchReply, error)
- func (g *GDS) Shutdown()
- func (g *GDS) Status(ctx context.Context, in *gds.HealthCheck) (*gds.ServiceState, error)
- func (g *GDS) UseError(rpc string, code codes.Code, msg string) error
- func (g *GDS) UseFixture(rpc, path string) (err error)
- func (g *GDS) Verification(ctx context.Context, in *gds.VerificationRequest) (*gds.VerificationReply, error)
- func (g *GDS) VerifyContact(ctx context.Context, in *gds.VerifyContactRequest) (*gds.VerifyContactReply, error)
- type Members
- func (g *Members) Client() (client members.TRISAMembersClient, err error)
- func (m *Members) Details(ctx context.Context, in *members.DetailsRequest) (*members.MemberDetails, error)
- func (g *Members) DialOpts() (opts []grpc.DialOption)
- func (m *Members) List(ctx context.Context, in *members.ListRequest) (*members.ListReply, error)
- func (m *Members) Reset()
- func (g *Members) Shutdown()
- func (m *Members) Summary(ctx context.Context, in *members.SummaryRequest) (*members.SummaryReply, error)
- func (m *Members) UseError(rpc string, code codes.Code, msg string) error
- func (m *Members) UseFixture(rpc, path string) (err error)
- type Trtl
Constants ¶
const ( RegisterRPC = "Register" LookupRPC = "Lookup" SearchRPC = "Search" VerificationRPC = "Verification" VerifyContactRPC = "VerifyContact" StatusRPC = "Status" )
const ( ListRPC = "List" SummaryRPC = "Summary" DetailsRPC = "Details" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type GDS ¶
type GDS struct { gds.UnimplementedTRISADirectoryServer Calls map[string]int OnRegister func(context.Context, *gds.RegisterRequest) (*gds.RegisterReply, error) OnLookup func(context.Context, *gds.LookupRequest) (*gds.LookupReply, error) OnSearch func(context.Context, *gds.SearchRequest) (*gds.SearchReply, error) OnVerification func(context.Context, *gds.VerificationRequest) (*gds.VerificationReply, error) OnVerifyContact func(context.Context, *gds.VerifyContactRequest) (*gds.VerifyContactReply, error) OnStatus func(context.Context, *gds.HealthCheck) (*gds.ServiceState, error) // contains filtered or unexported fields }
GDS implements a mock gRPC server that listens on a buffconc and registers the TRISA directory service. The RPC methods are able to be set from individual tests so that the user can specify the return of the RPC in order to test specific functionality. The mock allows us to test dual GDS (TestNet and MainNet) handling from the BFF without having to set up a whole microservices architecture with data storage and managing fixtures.
To set the response of the mock for a particular test, update the GDS OnRPC method. e.g. to mock the Register RPC, set the OnRegister method. The number of calls to the RPC will be recorded to verifiy that the service is being called correctly. Use the Reset method to remove all RPC handlers and set calls back to 0.
NOTE: this mock is not safe for concurrent use. NOTE: if the OnRPC function is not set, the test will panic
func (*GDS) DialOpts ¶ added in v1.5.0
func (g *GDS) DialOpts() (opts []grpc.DialOption)
func (*GDS) Lookup ¶
func (g *GDS) Lookup(ctx context.Context, in *gds.LookupRequest) (*gds.LookupReply, error)
func (*GDS) Register ¶
func (g *GDS) Register(ctx context.Context, in *gds.RegisterRequest) (*gds.RegisterReply, error)
func (*GDS) Search ¶
func (g *GDS) Search(ctx context.Context, in *gds.SearchRequest) (*gds.SearchReply, error)
func (*GDS) Status ¶
func (g *GDS) Status(ctx context.Context, in *gds.HealthCheck) (*gds.ServiceState, error)
func (*GDS) UseError ¶
UseError allows you to specify a gRPC status error to return from the specified RPC.
func (*GDS) UseFixture ¶
UseFixture allows you to specify a JSON fixture that is loaded from disk as the protocol buffer response for the specified RPC, simplifying the handler mocking.
func (*GDS) Verification ¶
func (g *GDS) Verification(ctx context.Context, in *gds.VerificationRequest) (*gds.VerificationReply, error)
func (*GDS) VerifyContact ¶
func (g *GDS) VerifyContact(ctx context.Context, in *gds.VerifyContactRequest) (*gds.VerifyContactReply, error)
type Members ¶ added in v1.5.0
type Members struct { members.UnimplementedTRISAMembersServer Calls map[string]int OnList func(context.Context, *members.ListRequest) (*members.ListReply, error) OnSummary func(context.Context, *members.SummaryRequest) (*members.SummaryReply, error) OnDetails func(context.Context, *members.DetailsRequest) (*members.MemberDetails, error) // contains filtered or unexported fields }
Memberss implements a mock gRPC server that listens on a buffcon and registers the TRISA members service. The RPC methods are able to be set from individual tests so that the user can specify the return of the RPC in order to test specific functionality. The mock allows us to test dual members (TestNet and MainNet) handling from the BFF without having to set up a whole microservices architecture with data storage and managing fixtures.
To set the response of the mock for a particular test, update the Members OnRPC method. e.g. to mock the Summary RPC, set the OnSummary method. The number of calls to the RPC will be recorded to verifiy that the service is being called correctly. Use the Reset method to remove all RPC handlers and set calls back to 0.
NOTE: this mock is not safe for concurrent use. NOTE: if the OnRPC function is not set, the test will panic
func NewMembers ¶ added in v1.5.0
func NewMembers(conf config.MembersConfig) (m *Members, err error)
func (*Members) Client ¶ added in v1.5.0
func (g *Members) Client() (client members.TRISAMembersClient, err error)
func (*Members) Details ¶ added in v1.5.0
func (m *Members) Details(ctx context.Context, in *members.DetailsRequest) (*members.MemberDetails, error)
func (*Members) DialOpts ¶ added in v1.5.0
func (g *Members) DialOpts() (opts []grpc.DialOption)
func (*Members) Summary ¶ added in v1.5.0
func (m *Members) Summary(ctx context.Context, in *members.SummaryRequest) (*members.SummaryReply, error)
func (*Members) UseError ¶ added in v1.5.0
UseError allows you to specify a gRPC status error to return from the specified RPC.
func (*Members) UseFixture ¶ added in v1.5.0
UseFixture allows you to specify a JSON fixture that is loaded from disk as the protocol buffer response for the specified RPC, simplifying the handler mocking.