zap: Index | Files

package ztest

import ""

Package ztest provides low-level helpers for testing log output. These utilities are helpful in zap's own unit tests, but any assertions using them are strongly coupled to a single encoding.


Package Files

doc.go timeout.go writer.go

func Initialize Uses

func Initialize(factor string) func()

Initialize checks the environment and alters the timeout scale accordingly. It returns a function to undo the scaling.

func Sleep Uses

func Sleep(base time.Duration)

Sleep scales the sleep duration by $TEST_TIMEOUT_SCALE.

func Timeout Uses

func Timeout(base time.Duration) time.Duration

Timeout scales the provided duration by $TEST_TIMEOUT_SCALE.

type Buffer Uses

type Buffer struct {

Buffer is an implementation of zapcore.WriteSyncer that sends all writes to a bytes.Buffer. It has convenience methods to split the accumulated buffer on newlines.

func (*Buffer) Lines Uses

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

Lines returns the current buffer contents, split on newlines.

func (*Buffer) Stripped Uses

func (b *Buffer) Stripped() string

Stripped returns the current buffer contents with the last trailing newline stripped.

type Discarder Uses

type Discarder struct{ Syncer }

A Discarder sends all writes to ioutil.Discard.

func (*Discarder) Write Uses

func (d *Discarder) Write(b []byte) (int, error)

Write implements io.Writer.

type FailWriter Uses

type FailWriter struct{ Syncer }

FailWriter is a WriteSyncer that always returns an error on writes.

func (FailWriter) Write Uses

func (w FailWriter) Write(b []byte) (int, error)

Write implements io.Writer.

type ShortWriter Uses

type ShortWriter struct{ Syncer }

ShortWriter is a WriteSyncer whose write method never fails, but nevertheless fails to the last byte of the input.

func (ShortWriter) Write Uses

func (w ShortWriter) Write(b []byte) (int, error)

Write implements io.Writer.

type Syncer Uses

type Syncer struct {
    // contains filtered or unexported fields

A Syncer is a spy for the Sync portion of zapcore.WriteSyncer.

func (*Syncer) Called Uses

func (s *Syncer) Called() bool

Called reports whether the Sync method was called.

func (*Syncer) SetError Uses

func (s *Syncer) SetError(err error)

SetError sets the error that the Sync method will return.

func (*Syncer) Sync Uses

func (s *Syncer) Sync() error

Sync records that it was called, then returns the user-supplied error (if any).

Package ztest imports 8 packages (graph) and is imported by 1 packages. Updated 2019-12-10. Refresh now. Tools for package owners.