hivetest

package
v1.15.0-pre.1 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package hivetest makes testing components using hive easier.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Lifecycle

func Lifecycle(tb testing.TB) *lifecycle

Lifecycle returns a hive.Lifecycle which executes start hooks immediately and queues stop hooks for the end of the test.

Types

type MockHealthReporter

type MockHealthReporter struct {
	lock.Mutex
	// contains filtered or unexported fields
}

MockHealthReporter is a mock implementation of cell.HealthReporter type. It provides a minimal implementation that can notify on events via an unbuffered channel. Further updates will block until all events are observed.

Empty initialization provides an implementation that is a no-op and will not notify on any updates.

func NewMockHealthReporter

func NewMockHealthReporter() *MockHealthReporter

NewMockHealthReporter creates a new mock health reporter which will block until the event is consumed on the Wait channel.

func (*MockHealthReporter) Degraded

func (m *MockHealthReporter) Degraded(msg string, err error)

Degraded updates with Degraded status.

func (*MockHealthReporter) OK

func (m *MockHealthReporter) OK(msg string)

OK updates with OK status.

func (*MockHealthReporter) Stopped

func (m *MockHealthReporter) Stopped(msg string)

Degraded updates with Stopped status, but will not actually stop the test reporter.

func (*MockHealthReporter) Wait

func (m *MockHealthReporter) Wait() <-chan Update

Wait returns a channel that will receive updates on the health status.

type Update

type Update struct {
	Event string
	Err   error
}

Update is a single update to the health status. We don't use the cell.Update type as it contains other fields that are not relevant to the test fixture.

Jump to

Keyboard shortcuts

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