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(base time.Duration)
Sleep scales the sleep duration by $TEST_TIMEOUT_SCALE.
func Timeout(base time.Duration) time.Duration
Timeout scales the provided duration by $TEST_TIMEOUT_SCALE.
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.
type Buffer struct { bytes.Buffer Syncer }
func (b *Buffer) Lines() []string
Lines returns the current buffer contents, split on newlines.
func (b *Buffer) Stripped() string
Stripped returns the current buffer contents with the last trailing newline stripped.
A Discarder sends all writes to io.Discard.
type Discarder struct{ Syncer }
func (d *Discarder) Write(b []byte) (int, error)
Write implements io.Writer.
FailWriter is a WriteSyncer that always returns an error on writes.
type FailWriter struct{ Syncer }
func (w FailWriter) Write(b []byte) (int, error)
Write implements io.Writer.
MockClock is a fake source of time. It implements standard time operations, but allows the user to control the passage of time.
Use the [Add] method to progress time.
type MockClock struct {
// contains filtered or unexported fields
}
func NewMockClock() *MockClock
NewMockClock builds a new mock clock using the current actual time as the initial time.
func (c *MockClock) Add(d time.Duration)
Add progresses time by the given duration. Other operations waiting for the time to advance will be resolved if they are within range.
Side effects of operations waiting for the time to advance will take effect on a best-effort basis. Avoid racing with operations that have side effects.
Panics if the duration is negative.
func (c *MockClock) NewTicker(d time.Duration) *time.Ticker
NewTicker returns a time.Ticker that ticks at the specified frequency.
As with time.NewTicker, the ticker will drop ticks if the receiver is slow, and the channel is never closed.
Calling Stop on the returned ticker is a no-op. The ticker only runs when the clock is advanced.
func (c *MockClock) Now() time.Time
Now reports the current time.
ShortWriter is a WriteSyncer whose write method never fails, but nevertheless fails to the last byte of the input.
type ShortWriter struct{ Syncer }
func (w ShortWriter) Write(b []byte) (int, error)
Write implements io.Writer.
A Syncer is a spy for the Sync portion of zapcore.WriteSyncer.
type Syncer struct {
// contains filtered or unexported fields
}
func (s *Syncer) Called() bool
Called reports whether the Sync method was called.
func (s *Syncer) SetError(err error)
SetError sets the error that the Sync method will return.
func (s *Syncer) Sync() error
Sync records that it was called, then returns the user-supplied error (if any).