testext

package
v0.1.6 Latest Latest
Warning

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

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

Documentation

Overview

Code generated by Frodo - DO NOT EDIT.

Timestamp: Fri, 15 Nov 2024 12:49:03 EST
Source:    other_service.go
Generator: https://github.com/bridgekit-io/frodo

Code generated by Frodo - DO NOT EDIT.

Timestamp: Fri, 15 Nov 2024 12:49:03 EST
Source:    other_service.go
Generator: https://github.com/bridgekit-io/frodo

Code generated by Frodo - DO NOT EDIT.

Timestamp: Fri, 15 Nov 2024 12:49:04 EST
Source:    sample_service.go
Generator: https://github.com/bridgekit-io/frodo

Code generated by Frodo - DO NOT EDIT.

Timestamp: Fri, 15 Nov 2024 12:49:05 EST
Source:    sample_service.go
Generator: https://github.com/bridgekit-io/frodo

Code generated by Frodo - DO NOT EDIT.

Timestamp: Fri, 15 Nov 2024 12:49:04 EST
Source:    sample_service.go
Generator: https://github.com/bridgekit-io/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)
	Chain1Func                 func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	Chain1GroupFooBarFunc      func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	Chain1GroupStarFunc        func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	Chain2Func                 func(context.Context, *testext.SampleRequest) (*testext.SampleResponse, error)
	Chain2OnErrorFunc          func(context.Context, *testext.FailAlwaysErrorRequest) (*testext.FailAlwaysErrorResponse, error)
	Chain2OnSuccessFunc        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)
	SecureWithRolesAliasedFunc 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
		Chain1                 callsSampleServiceChain1
		Chain1GroupFooBar      callsSampleServiceChain1GroupFooBar
		Chain1GroupStar        callsSampleServiceChain1GroupStar
		Chain2                 callsSampleServiceChain2
		Chain2OnError          callsSampleServiceChain2OnError
		Chain2OnSuccess        callsSampleServiceChain2OnSuccess
		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
		SecureWithRolesAliased callsSampleServiceSecureWithRolesAliased
		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) Chain1

func (*MockSampleService) Chain1GroupFooBar

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

func (*MockSampleService) Chain1GroupStar

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

func (*MockSampleService) Chain2

func (*MockSampleService) Chain2OnError

func (*MockSampleService) Chain2OnSuccess

func (mock *MockSampleService) Chain2OnSuccess(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

func (*MockSampleService) ListenerA

func (*MockSampleService) ListenerB

func (*MockSampleService) OmitMe

func (*MockSampleService) OnFailAlways

func (*MockSampleService) Panic

func (*MockSampleService) Redirect

func (*MockSampleService) SecureWithRoles

func (*MockSampleService) SecureWithRolesAliased

func (mock *MockSampleService) SecureWithRolesAliased(ctx context.Context, request *testext.SampleSecurityRequest) (*testext.SampleSecurityResponse, error)

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