testutils

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2023 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ShouldResembleProto

func ShouldResembleProto(actual interface{}, expected ...interface{}) string

ShouldResembleProto asserts that given two values that contain proto messages are equal by comparing their types and ensuring they serialize to the same text representation.

Values can either each be a proto.Message or a slice of values that each implement proto.Message interface.

func VerifyGrpcError added in v0.2.0

func VerifyGrpcError(actual error, expect errors.GrpcError)

Types

type Container added in v0.2.0

type Container interface {
	GetBoundIP(id string) string
	GetPort(id string) string
}

type DockerInstance added in v0.2.0

type DockerInstance struct {
	Pool      *dockertest.Pool
	Container *dockertest.Resource
}

func NewDockerInstance added in v0.2.0

func NewDockerInstance(opts TestDatabaseOptions) (*DockerInstance, error)

func (*DockerInstance) Close added in v0.2.0

func (d *DockerInstance) Close(close func() error) (retErr error)

func (*DockerInstance) MustClose added in v0.2.0

func (d *DockerInstance) MustClose(close func() error)

type Response added in v0.2.0

type Response struct {
	Cookies []*http.Cookie
	Headers http.Header
}

type TestDatabaseOptions added in v0.2.0

type TestDatabaseOptions struct {
	ContainerExpiredTime uint
	Image                string
	Tag                  string
	Env                  []string
	Init                 func(Container) error
}

type TestGrpcServer added in v0.2.0

type TestGrpcServer struct {
	Server *grpc.Server
	// contains filtered or unexported fields
}

func NewTestGrpcServer added in v0.2.0

func NewTestGrpcServer(ctx context.Context) *TestGrpcServer

func (*TestGrpcServer) Dial added in v0.2.0

func (t *TestGrpcServer) Dial() *grpc.ClientConn

func (*TestGrpcServer) Start added in v0.2.0

func (t *TestGrpcServer) Start()

func (*TestGrpcServer) Stop added in v0.2.0

func (t *TestGrpcServer) Stop()

type TestHttpServer added in v0.2.0

type TestHttpServer struct {
	Server *httptest.Server
	// contains filtered or unexported fields
}

func NewTestHttpServer added in v0.2.0

func NewTestHttpServer(controller httpApp.Controller) TestHttpServer

func (*TestHttpServer) MustDoForm added in v0.2.0

func (c *TestHttpServer) MustDoForm(t *testing.T, method string, url string, reqBody url.Values, respBody interface{}, statusCode int) *Response

func (*TestHttpServer) MustDoJSON added in v0.2.0

func (c *TestHttpServer) MustDoJSON(t *testing.T, method string, url string, reqBody interface{}, respBody interface{}, statusCode int) *Response

func (*TestHttpServer) MustFailedForm added in v0.2.0

func (c *TestHttpServer) MustFailedForm(t *testing.T, method string, path string, reqBody url.Values, err errors.HttpError)

func (*TestHttpServer) MustFailedJSON added in v0.2.0

func (c *TestHttpServer) MustFailedJSON(t *testing.T, method string, path string, reqBody interface{}, err errors.HttpError)

func (*TestHttpServer) WithCookie added in v0.2.0

func (c *TestHttpServer) WithCookie(value string) *TestHttpServer

func (*TestHttpServer) WithHeader added in v0.2.0

func (c *TestHttpServer) WithHeader(key string, value string) *TestHttpServer

Jump to

Keyboard shortcuts

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