testutils

package
v0.7.6 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2019 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TestErr              = errors.New("error")
	TestErrStr           = `{"error":"error"}`
	TestErrBadRequestStr = `{"error":"Bad Request"}`
	TestSuccessStr       = `{}`
)
View Source
var (
	ErrTimeout = errors.New("waitgroup timeout")
)

Functions

func CreateTestRequest

func CreateTestRequest(t *testing.T, msg gin.H, b binding.Binding) (*httptest.ResponseRecorder, *gin.Context)

CreateTestRequest creates gin TestContext and inject request data in context and return.

func ReservePort

func ReservePort() int

ReservePort automatically reserves available port in system.

Types

type TimeoutWaitGroup

type TimeoutWaitGroup struct {
	sync.WaitGroup
	// contains filtered or unexported fields
}

TimeoutWaitGroup is a WaitGroup with timeout support.

func NewTimeoutWaitGroup

func NewTimeoutWaitGroup(timeout time.Duration) *TimeoutWaitGroup

NewTimeoutWaitGroup creates new WaitGroup with timeout.

func (*TimeoutWaitGroup) Wait

func (twg *TimeoutWaitGroup) Wait() error

Wait blocks until the WaitGroup counter is zero. An ErrTimeout is returned if it exceeds timeout.

Jump to

Keyboard shortcuts

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