watcher

package
v0.0.0-...-16fef41 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeout = errors.New("timeout")

ErrTimeout denotes that the Watcher timed out waiting for remaining data to be observed.

Functions

func Create

func Create(verifyOrder bool, names ...string) flow.Runnable

Types

type TestingT

type TestingT interface {
	Error(args ...interface{})
	Errorf(format string, args ...interface{})
	Fail()
	FailNow()
}

TestingT is an interface wrapper around *testing.T

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

func New

func New(verifyOrder bool) *Watcher

func NewOrdered

func NewOrdered() *Watcher

NewOrdered creates a Watcher that expects observed data to match the ordering of the expected data.

func NewUnordered

func NewUnordered() *Watcher

func (*Watcher) Add

func (w *Watcher) Add(data ...interface{})

Add is called after the network operation completes successfully and adds `data` to the `expected` slice so that it can be compared to the `observed` data at the end of the test scenario. Use Prepare and Add together when created expected data while a separate goroutine that calls Observer is running.

func (*Watcher) Assert

func (w *Watcher) Assert(t TestingT, timeout time.Duration) bool

Assert waits for up to `timeout` for all expected data to be observed and asserts the expected and observed data are either equal (in order) or have matching elemenets (out of order is acceptable).

func (*Watcher) AssertNotDelivered

func (w *Watcher) AssertNotDelivered(t TestingT, timeout time.Duration) bool

func (*Watcher) Expect

func (w *Watcher) Expect(data ...interface{})

Expect adds data to both the `remaining` map add the expected slice in a single call. Use this only when a test scenario can prepare the expected data prior to an Observe calls.

func (*Watcher) ExpectBytes

func (w *Watcher) ExpectBytes(data ...byte)

ExpectBytes provides a simple function to add expected bytes.

func (*Watcher) ExpectI16s

func (w *Watcher) ExpectI16s(data ...int16)

ExpectI16s provides a simple function to add expected int16s.

func (*Watcher) ExpectI32s

func (w *Watcher) ExpectI32s(data ...int32)

ExpectI32s provides a simple function to add expected int32s.

func (*Watcher) ExpectI64s

func (w *Watcher) ExpectI64s(data ...int64)

ExpectI64s provides a simple function to add expected int64s.

func (*Watcher) ExpectI8s

func (w *Watcher) ExpectI8s(data ...int8)

ExpectI8s provides a simple function to add expected int8s.

func (*Watcher) ExpectInts

func (w *Watcher) ExpectInts(data ...int)

ExpectInts provides a simple function to add expected integers.

func (*Watcher) ExpectRunes

func (w *Watcher) ExpectRunes(data ...rune)

ExpectRunes provides a simple function to add expected runes.

func (*Watcher) ExpectStrings

func (w *Watcher) ExpectStrings(data ...string)

ExpectStrings provides a simple function to add expected strings.

func (*Watcher) ExpectU16s

func (w *Watcher) ExpectU16s(data ...uint16)

ExpectU16s provides a simple function to add expected uint16s.

func (*Watcher) ExpectU32s

func (w *Watcher) ExpectU32s(data ...uint32)

ExpectU32s provides a simple function to add expected uint32s.

func (*Watcher) ExpectU64s

func (w *Watcher) ExpectU64s(data ...uint64)

ExpectU64s provides a simple function to add expected uint64s.

func (*Watcher) ExpectUInts

func (w *Watcher) ExpectUInts(data ...uint)

ExpectUInts provides a simple function to add expected unsigned integers.

func (*Watcher) FailIfNotExpected

func (w *Watcher) FailIfNotExpected(t TestingT, data ...interface{})

func (*Watcher) Observe

func (w *Watcher) Observe(data ...interface{})

Observe adds any data that is in `remaining` to the `observed` slice. If the the watcher is closable (all expected data captured) and there is no more remaining data to observe, then the finish channel is closed.

func (*Watcher) ObserveJSON

func (w *Watcher) ObserveJSON(data ...interface{})

ObserveJSON adds any json data that is in `remaining` to the `observed` slice. If the the watcher is closable (all expected data captured) and there is no more remaining data to observe, then the finish channel is closed.

func (*Watcher) Partial

func (w *Watcher) Partial(t TestingT, timeout time.Duration) (TestingT, interface{}, interface{})

Partial waits for up to `timeout` for any expected data to be observed and returns the expected and observed slices even if not complete.

func (*Watcher) Prepare

func (w *Watcher) Prepare(data ...interface{})

Prepare is called before a network operation is called to add expected `data` to the `remaining` map. This is so that Observe can verify the data is expected and add it to the `observed` slice. Use Prepare and Add together when created expected data while a separate goroutine that calls Observer is running.

func (*Watcher) Remove

func (w *Watcher) Remove(data ...interface{})

Remove is called if the network operation fails and removes `data` from the `remaining` map added during `Prepare`. This is so that if the `Publish` ' operation fails, `data` added for tracking could be removed afterwards.

func (*Watcher) Require

func (w *Watcher) Require(t TestingT, timeout time.Duration)

Assert waits for up to `timeout` for all expected data to be observed and requires the expected and observed data are either equal (in order) or have matching elemenets (out of order is acceptable).

func (*Watcher) Reset

func (w *Watcher) Reset()

Reset clears all the underlying state and returns the watcher to a initial state.

func (*Watcher) Result

func (w *Watcher) Result(t TestingT, timeout time.Duration) (TestingT, interface{}, interface{})

Result waits for up to `timeout` for all expected data to be observed and returns the expected and observed slices.

func (*Watcher) WaitForResult

func (w *Watcher) WaitForResult(timeout time.Duration) error

WaitForResult waits for up to `timeout` for all expected data to be observed and returns an error if expected and observed data differ.

Jump to

Keyboard shortcuts

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