testutils

package
v1.0.0-beta1 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2017 License: MIT Imports: 7 Imported by: 0

README

Test utilities

The functionality in this package is exposed both for internal testing as well as service testability.

InMemoryLogger

If you'd like to verify that log messages are logged properly, use the WithInMemoryLogger() helper which will provider you with a zap.Logger you can pass into a service and capture recorded messages.

Overriding environment variables

If you'd like to override environment variables, use the env.Override() helper and defer the reset to ensure the old value us returned at the end of the test.

Documentation

Overview

Package testutils is the Test utilities.

The functionality in this package is exposed both for internal testing as well as service testability.

InMemoryLogger

If you'd like to verify that log messages are logged properly, use the WithInMemoryLogger() helper which will provider you with a zap.Logger you can pass into a service and capture recorded messages.

Overriding environment variables

If you'd like to override environment variables, use the env.Override() helper and defer the reset to ensure the old value us returned at the end of the test.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StaticAppData

func StaticAppData(serviceName *string) config.Provider

StaticAppData creates a Provider for a valid appID/owner

func WithInMemoryLogger

func WithInMemoryLogger(t *testing.T, opts []zap.Option, f func(zap.Logger, *TestBuffer))

WithInMemoryLogger creates an in-memory zap logger that can be used in tests

Types

type ErrorCloser

type ErrorCloser struct{}

ErrorCloser is a nop implementation of io.Closer

func (ErrorCloser) Close

func (ec ErrorCloser) Close() error

Close implements io.Closer

type NopCloser

type NopCloser struct{}

NopCloser is a nop implementation of io.Closer

func (NopCloser) Close

func (nc NopCloser) Close() error

Close implements io.Closer

type TestBuffer

type TestBuffer struct {
	bytes.Buffer
}

TestBuffer is a buffer used to test the zap logger

func (*TestBuffer) Lines

func (b *TestBuffer) Lines() []string

Lines returns buffer as array of strings

func (*TestBuffer) Stripped

func (b *TestBuffer) Stripped() string

Stripped returns buffer as a string without the newline

func (*TestBuffer) Sync

func (b *TestBuffer) Sync() error

Sync is a nop to conform to zap.WriteSyncer interface

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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