testutil

package
Version: v2.0.0-...-675b67f Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2021 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewBuildContext

func NewBuildContext(t testing.TB) operator.BuildContext

NewBuildContext will return a new build context for testing

func NewTempDir

func NewTempDir(t testing.TB) string

NewTempDir will return a new temp directory for testing

func NewTestDatabase

func NewTestDatabase(t testing.TB) *bbolt.DB

NewTestDatabase will return a new database 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 interface{})

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) 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 entry

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

GetOutputIDs returns the list of connected outputs.

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(ctx 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 will set the connected outputs' IDs.

func (*FakeOutput) SetOutputs

func (f *FakeOutput) SetOutputs(outputs []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 MockOperator

type MockOperator struct {
	mock.Mock
}

MockOperator is an autogenerated mock type for the MockOperator type

func NewMockOperator

func NewMockOperator(id string) *MockOperator

NewMockOperator will return a basic operator mock

func (*MockOperator) CanOutput

func (o *MockOperator) CanOutput() bool

CanOutput indicates if the operator will output entries to other operators.

func (*MockOperator) CanProcess

func (o *MockOperator) CanProcess() bool

CanProcess indicates if the operator will process entries from other operators.

func (*MockOperator) GetOutputIDs

func (o *MockOperator) GetOutputIDs() []string

GetOutputIDs returns the list of connected outputs.

func (*MockOperator) ID

func (o *MockOperator) ID() string

ID returns the id of the operator.

func (*MockOperator) Logger

func (o *MockOperator) Logger() *zap.SugaredLogger

Logger returns the operator's logger

func (*MockOperator) Outputs

func (o *MockOperator) Outputs() []operator.Operator

Outputs returns the list of connected outputs.

func (*MockOperator) Process

func (o *MockOperator) Process(ctx context.Context, e *entry.Entry) error

Process will process an entry from an operator.

func (*MockOperator) SetOutputIDs

func (o *MockOperator) SetOutputIDs(ids []string)

SetOutputIDs will set the connected outputs' IDs.

func (*MockOperator) SetOutputs

func (o *MockOperator) SetOutputs(operators []operator.Operator) error

SetOutputs will set the connected outputs.

func (*MockOperator) Start

func (o *MockOperator) Start(p operator.Persister) error

Start will start the operator.

func (*MockOperator) Stop

func (o *MockOperator) Stop() error

Stop will stop the operator.

func (*MockOperator) Type

func (o *MockOperator) Type() string

Type returns the type of the operator.

type MockPersister

type MockPersister struct {
	mock.Mock
}

func (*MockPersister) Delete

func (m *MockPersister) Delete(ctx context.Context, key string) error

func (*MockPersister) Get

func (m *MockPersister) Get(ctx context.Context, key string) ([]byte, error)

func (*MockPersister) Set

func (m *MockPersister) Set(ctx context.Context, key string, value []byte) error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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