testutil

package
v0.99.0 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Logger

func Logger(t testing.TB) *zap.SugaredLogger

Logger will return a new tesst logger

func NewErrPersister added in v0.88.0

func NewErrPersister(errKeys map[string]error) operator.Persister

NewErrPersister will return a new persister for testing which will return an error if any of the specified keys are used

func NewMockPersister

func NewMockPersister(scope string) operator.Persister

func NewUnscopedMockPersister

func NewUnscopedMockPersister() operator.Persister

NewUnscopedMockPersister will return a new persister for testing

func Trim

func Trim(s string) string

Trim removes white space from the lines of a string

Types

type FakeOutput

type FakeOutput struct {
	Received chan *entry.Entry
	*zap.SugaredLogger
}

FakeOutput is an empty output used primarily for testing

func NewFakeOutput

func NewFakeOutput(t testing.TB) *FakeOutput

NewFakeOutput creates a new fake output with default settings

func (*FakeOutput) CanOutput

func (f *FakeOutput) CanOutput() bool

CanOutput always returns false for a fake output

func (*FakeOutput) CanProcess

func (f *FakeOutput) CanProcess() bool

CanProcess always returns true for a fake output

func (*FakeOutput) ExpectBody

func (f *FakeOutput) ExpectBody(t testing.TB, body any)

ExpectBody expects that a body will be received by the fake operator within a second and that it is equal to the given body

func (*FakeOutput) ExpectEntries added in v0.94.0

func (f *FakeOutput) ExpectEntries(t testing.TB, expected []*entry.Entry)

ExpectEntries expects that the given entries will be received in any order

func (*FakeOutput) ExpectEntry

func (f *FakeOutput) ExpectEntry(t testing.TB, expected *entry.Entry)

ExpectEntry expects that an entry will be received by the fake operator within a second and that it is equal to the given body

func (*FakeOutput) ExpectNoEntry

func (f *FakeOutput) ExpectNoEntry(t testing.TB, timeout time.Duration)

ExpectNoEntry expects that no entry will be received within the specified time

func (*FakeOutput) GetOutputIDs

func (f *FakeOutput) GetOutputIDs() []string

Outputs always returns nil for a fake output

func (*FakeOutput) ID

func (f *FakeOutput) ID() string

ID always returns `fake` as the ID of a fake output operator

func (*FakeOutput) Logger

func (f *FakeOutput) Logger() *zap.SugaredLogger

Logger returns the logger of a fake output

func (*FakeOutput) Outputs

func (f *FakeOutput) Outputs() []operator.Operator

Outputs always returns nil for a fake output

func (*FakeOutput) Process

func (f *FakeOutput) Process(_ context.Context, entry *entry.Entry) error

Process will place all incoming entries on the Received channel of a fake output

func (*FakeOutput) SetOutputIDs

func (f *FakeOutput) SetOutputIDs(_ []string)

SetOutputIDs immediately returns nil for a fake output

func (*FakeOutput) SetOutputs

func (f *FakeOutput) SetOutputs(_ []operator.Operator) error

SetOutputs immediately returns nil for a fake output

func (*FakeOutput) Start

func (f *FakeOutput) Start(_ operator.Persister) error

Start immediately returns nil for a fake output

func (*FakeOutput) Stop

func (f *FakeOutput) Stop() error

Stop immediately returns nil for a fake output

func (*FakeOutput) Type

func (f *FakeOutput) Type() string

Type always return `fake_output` for a fake output

type Operator

type Operator struct {
	mock.Mock
}

Operator is an autogenerated mock type for the Operator type

func NewMockOperator

func NewMockOperator(id string) *Operator

NewMockOperator will return a basic operator mock

func (*Operator) CanOutput

func (_m *Operator) CanOutput() bool

CanOutput provides a mock function with given fields:

func (*Operator) CanProcess

func (_m *Operator) CanProcess() bool

CanProcess provides a mock function with given fields:

func (*Operator) GetOutputIDs

func (_m *Operator) GetOutputIDs() []string

GetOutputIDs provides a mock function with given fields:

func (*Operator) ID

func (_m *Operator) ID() string

ID provides a mock function with given fields:

func (*Operator) Logger

func (_m *Operator) Logger() *zap.SugaredLogger

Logger provides a mock function with given fields:

func (*Operator) Outputs

func (_m *Operator) Outputs() []operator.Operator

Outputs provides a mock function with given fields:

func (*Operator) Process

func (_m *Operator) Process(_a0 context.Context, _a1 *entry.Entry) error

Process provides a mock function with given fields: _a0, _a1

func (*Operator) SetOutputIDs

func (_m *Operator) SetOutputIDs(_a0 []string)

SetOutputIDs provides a mock function with given fields: _a0

func (*Operator) SetOutputs

func (_m *Operator) SetOutputs(_a0 []operator.Operator) error

SetOutputs provides a mock function with given fields: _a0

func (*Operator) Start

func (_m *Operator) Start(_a0 operator.Persister) error

Start provides a mock function with given fields: _a0

func (*Operator) Stop

func (_m *Operator) Stop() error

Stop provides a mock function with given fields:

func (*Operator) Type

func (_m *Operator) Type() string

Type provides a mock function with given fields:

Jump to

Keyboard shortcuts

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