Documentation ¶
Index ¶
- Constants
- type GDS
- func (g *GDS) Client() (client gds.TRISADirectoryClient, err error)
- 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)
Constants ¶
const ( RegisterRPC = "Register" LookupRPC = "Lookup" SearchRPC = "Search" VerificationRPC = "Verification" VerifyContactRPC = "VerifyContact" StatusRPC = "Status" )
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) 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)