test

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CaptureLogsForTest

func CaptureLogsForTest() func() []string

CaptureLogsForTest adds a logging listener which captures messages to an internal channel. Returns a function that ends log capturing and returns any captured messages. It's safe to call endCapture() multiple times, so a simple call pattern is:

endCapture := CaptureLogsForTest()
defer endCapture()  // ensure cleanup in case of test assert failures

/* some test code */

messages := endCapture()
/* do inspection of log messages */

func CaptureLogsForTestWithChannel

func CaptureLogsForTestWithChannel(messagesCh chan string) func() []string

func EnableStdoutLogging

func EnableStdoutLogging()

EnableStdoutLogging turns on logging to stdout for diagnostics.

func RandomString added in v0.1.1

func RandomString(prefix string, length int) string

RandomString generates a random string with prefix

func RequireClose added in v0.2.0

func RequireClose(t *testing.T, closeable interface {
	Close(ctx context.Context) error
})

func RequireContextHasDefaultTimeout added in v0.4.0

func RequireContextHasDefaultTimeout(t *testing.T, ctx context.Context, timeout time.Duration)

RequireContextHasDefaultTimeout checks that the context has a deadline set, and that it's using the right timeout. NOTE: There's some wiggle room since some time will expire before this is called.

Types

type ConnectionParamsForTest added in v0.1.1

type ConnectionParamsForTest struct {
	ConnectionString        string
	EventHubName            string
	EventHubNamespace       string
	ResourceGroup           string
	StorageConnectionString string
	SubscriptionID          string
}

func GetConnectionParamsForTest added in v0.1.1

func GetConnectionParamsForTest(t *testing.T) ConnectionParamsForTest

Jump to

Keyboard shortcuts

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