testext

package
v0.1.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 7, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Code generated by Frodo - DO NOT EDIT.

Timestamp: Thu, 07 Mar 2024 09:43:11 EST
Source:    other_service.go
Generator: https://github.com/bridgekitio/frodo

Code generated by Frodo - DO NOT EDIT.

Timestamp: Thu, 07 Mar 2024 09:43:11 EST
Source:    other_service.go
Generator: https://github.com/bridgekitio/frodo

Code generated by Frodo - DO NOT EDIT.

Timestamp: Thu, 07 Mar 2024 09:43:12 EST
Source:    sample_service.go
Generator: https://github.com/bridgekitio/frodo

Code generated by Frodo - DO NOT EDIT.

Timestamp: Thu, 07 Mar 2024 09:43:13 EST
Source:    sample_service.go
Generator: https://github.com/bridgekitio/frodo

Code generated by Frodo - DO NOT EDIT.

Timestamp: Thu, 07 Mar 2024 09:43:12 EST
Source:    sample_service.go
Generator: https://github.com/bridgekitio/frodo

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func OtherServiceClient

func OtherServiceClient(address string, options ...clients.ClientOption) testext.OtherService

OtherServiceClient creates an RPC client that conforms to the OtherService interface, but delegates work to remote instances. You must supply the base address of the remote service gateway instance or the load balancer for that service.

OtherService primarily exists to show that we can send event signals between services.

func OtherServiceServer

func OtherServiceServer(handler testext.OtherService, middleware ...services.MiddlewareFunc) *services.Service

OtherServiceServer accepts your "real" OtherService instance (the thing that really does the work), and returns a set of endpoint routes which allow this service to be consumed via the gateways/listeners you configure in main().

// Example
serviceHandler := testext.OtherServiceHandler{ /* set up to your liking */ }
server := services.New(
	services.Listen(apis.NewGateway()),
	services.Register(testextgen.OtherServiceServer(serviceHandler)),
)
server.Listen()

From there, you can add middleware, event sourcing support and more. Look at the frodo documentation for more details/examples on how to make your service production ready.

func SampleServiceClient

func SampleServiceClient(address string, options ...clients.ClientOption) testext.SampleService

SampleServiceClient creates an RPC client that conforms to the SampleService interface, but delegates work to remote instances. You must supply the base address of the remote service gateway instance or the load balancer for that service.

SampleService is a mix of different options, parameter setups, and responses so that we can run integration tests using our code-generated clients. Each method is nothing special, but they each do something a little differently than the rest to flex different parts of the framework.

func SampleServiceServer

func SampleServiceServer(handler testext.SampleService, middleware ...services.MiddlewareFunc) *services.Service

SampleServiceServer accepts your "real" SampleService instance (the thing that really does the work), and returns a set of endpoint routes which allow this service to be consumed via the gateways/listeners you configure in main().

// Example
serviceHandler := testext.SampleServiceHandler{ /* set up to your liking */ }
server := services.New(
	services.Listen(apis.NewGateway()),
	services.Register(testextgen.SampleServiceServer(serviceHandler)),
)
server.Listen()

From there, you can add middleware, event sourcing support and more. Look at the frodo documentation for more details/examples on how to make your service production ready.

Types

type MockSampleService

type MockSampleService struct {
	AuthorizationFunc     func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	ComplexValuesFunc     func(context.Context, *testext.SampleComplexRequest) (*testext.SampleComplexResponse, error)
	ComplexValuesPathFunc func(context.Context, *testext.SampleComplexRequest) (*testext.SampleComplexResponse, error)
	CustomRouteFunc       func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	CustomRouteBodyFunc   func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	CustomRouteQueryFunc  func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	DefaultsFunc          func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	DownloadFunc          func(context.Context, *testext.SampleDownloadRequest) (*testext.SampleDownloadResponse, error)
	DownloadResumableFunc func(context.Context, *testext.SampleDownloadRequest) (*testext.SampleDownloadResponse, error)
	Fail4XXFunc           func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	Fail5XXFunc           func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	FailAlwaysFunc        func(context.Context, *testext.FailAlwaysRequest) (*testext.FailAlwaysResponse, error)
	ListenerAFunc         func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	ListenerBFunc         func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	OmitMeFunc            func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	OnFailAlwaysFunc      func(context.Context, *testext.FailAlwaysErrorRequest) (*testext.FailAlwaysErrorResponse, error)
	PanicFunc             func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	RedirectFunc          func(context.Context, *testext.SampleRedirectRequest) (*testext.SampleRedirectResponse, error)
	SecureWithRolesFunc   func(context.Context, *testext.SampleSecurityRequest) (*testext.SampleSecurityResponse, error)
	SleepFunc             func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	TriggerFailureFunc    func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	TriggerLowerCaseFunc  func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	TriggerUpperCaseFunc  func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)

	Calls struct {
		Authorization     callsSampleServiceAuthorization
		ComplexValues     callsSampleServiceComplexValues
		ComplexValuesPath callsSampleServiceComplexValuesPath
		CustomRoute       callsSampleServiceCustomRoute
		CustomRouteBody   callsSampleServiceCustomRouteBody
		CustomRouteQuery  callsSampleServiceCustomRouteQuery
		Defaults          callsSampleServiceDefaults
		Download          callsSampleServiceDownload
		DownloadResumable callsSampleServiceDownloadResumable
		Fail4XX           callsSampleServiceFail4XX
		Fail5XX           callsSampleServiceFail5XX
		FailAlways        callsSampleServiceFailAlways
		ListenerA         callsSampleServiceListenerA
		ListenerB         callsSampleServiceListenerB
		OmitMe            callsSampleServiceOmitMe
		OnFailAlways      callsSampleServiceOnFailAlways
		Panic             callsSampleServicePanic
		Redirect          callsSampleServiceRedirect
		SecureWithRoles   callsSampleServiceSecureWithRoles
		Sleep             callsSampleServiceSleep
		TriggerFailure    callsSampleServiceTriggerFailure
		TriggerLowerCase  callsSampleServiceTriggerLowerCase
		TriggerUpperCase  callsSampleServiceTriggerUpperCase
	}
}

MockSampleService allows you to program behaviors into a mock instance of SampleService. You supply dynamic functions named "XxxFunc" to provide the custom behavior; so if your service has a function called 'CreateUser', you supply a function for 'CreateUserFunc'.

You do not need to supply behaviors for every single service function; just the ones you plan to test. If you do invoke a function without a programmed behavior, it will just return an error with a message indicating that it wasn't implemented.

func (*MockSampleService) Authorization

func (mock *MockSampleService) Authorization(ctx context.Context, request *testext.SampleRequest) (*testext.SampleResponse, error)

func (*MockSampleService) ComplexValues

func (*MockSampleService) ComplexValuesPath

func (*MockSampleService) CustomRoute

func (mock *MockSampleService) CustomRoute(ctx context.Context, request *testext.SampleRequest) (*testext.SampleResponse, error)

func (*MockSampleService) CustomRouteBody

func (mock *MockSampleService) CustomRouteBody(ctx context.Context, request *testext.SampleRequest) (*testext.SampleResponse, error)

func (*MockSampleService) CustomRouteQuery

func (mock *MockSampleService) CustomRouteQuery(ctx context.Context, request *testext.SampleRequest) (*testext.SampleResponse, error)

func (*MockSampleService) Defaults

func (*MockSampleService) Download

func (*MockSampleService) DownloadResumable

func (*MockSampleService) Fail4XX

func (*MockSampleService) Fail5XX

func (*MockSampleService) FailAlways added in v0.1.4

func (*MockSampleService) ListenerA

func (*MockSampleService) ListenerB

func (*MockSampleService) OmitMe

func (*MockSampleService) OnFailAlways added in v0.1.4

func (*MockSampleService) Panic

func (*MockSampleService) Redirect

func (*MockSampleService) SecureWithRoles

func (*MockSampleService) Sleep

func (*MockSampleService) TriggerFailure

func (mock *MockSampleService) TriggerFailure(ctx context.Context, request *testext.SampleRequest) (*testext.SampleResponse, error)

func (*MockSampleService) TriggerLowerCase

func (mock *MockSampleService) TriggerLowerCase(ctx context.Context, request *testext.SampleRequest) (*testext.SampleResponse, error)

func (*MockSampleService) TriggerUpperCase

func (mock *MockSampleService) TriggerUpperCase(ctx context.Context, request *testext.SampleRequest) (*testext.SampleResponse, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL