test

package
v0.9.1 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CaseInvalidMethod        = "case: Invalid method"
	CaseClientIOError        = "case: Client IO error"
	CaseNotImplemented       = "case: Not implemented"
	CaseInfrastructureError  = "case: infrastructure error"
	CaseServiceReturnedError = "case: Service returned an error"
	CaseContentTypeError     = "case: Content type error"
)

Variables

View Source
var File_internal_test_test_proto protoreflect.FileDescriptor

Functions

This section is empty.

Types

type Client

type Client struct {
	*duh.Client
	// contains filtered or unexported fields
}

Client is a simple client that calls the Service

func NewClient

func NewClient(conf ClientConfig) *Client

func (*Client) TestErrors

func (c *Client) TestErrors(ctx context.Context, req *ErrorsRequest) error

TestErrors is used in test suite to test error handling

type ClientConfig

type ClientConfig struct {
	Endpoint string
	Client   *http.Client
}

type ErrorsRequest

type ErrorsRequest struct {
	Case string `protobuf:"bytes,1,opt,name=case,proto3" json:"case,omitempty"`
	// contains filtered or unexported fields
}

func (*ErrorsRequest) Descriptor deprecated

func (*ErrorsRequest) Descriptor() ([]byte, []int)

Deprecated: Use ErrorsRequest.ProtoReflect.Descriptor instead.

func (*ErrorsRequest) GetCase

func (x *ErrorsRequest) GetCase() string

func (*ErrorsRequest) ProtoMessage

func (*ErrorsRequest) ProtoMessage()

func (*ErrorsRequest) ProtoReflect

func (x *ErrorsRequest) ProtoReflect() protoreflect.Message

func (*ErrorsRequest) Reset

func (x *ErrorsRequest) Reset()

func (*ErrorsRequest) String

func (x *ErrorsRequest) String() string

type Handler

type Handler struct {
	Service *Service
}

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

type Service

type Service struct{}

Service is an example of a production ready service implementation

func NewService

func NewService() *Service

NewService creates a new service instance

func (*Service) TestErrors

func (h *Service) TestErrors(ctx context.Context, req *ErrorsRequest) error

TestErrors will return a variety of errors depending on the req.Case provided. Suitable for testing client implementations. This method only responds with errors.

Jump to

Keyboard shortcuts

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