test

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package test provides tests for the generic rx package. Every operator / data type has its own subdirectory named after it containing one or more tests that exercise its functionality.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contex

func Contex(t T, description string, f func(T)) bool

Contex(t) block is used to describe the context in which the data type or method mentioned in the describe block is being used. The context description argument is used to fence off a specific context in which specific examples are to be performed.

func Describ

func Describ(e *testing.T, name string, f func(T)) bool

Describ(e) is used to describe a data type, method or an example group. This is the outer block which actually contains the test code and it depicts the characteristics of the code enclosed in it. The name argument is a reference to the module or data type being tested.

func Expec

func Expec(t T) expect

func I

func I(t T, description string, f func(T)) bool

I(t) describes the specification of the example in the context. The description argument can be considered as the function that the block is expected to perform or in other words it can be considered as a test case.

Types

type Assertion

type Assertion struct {
	*testing.T
}

Assertion represents all assertians that can be made.

func Asser

func Asser(t T) Assertion

Assert returns an assertion to me made.

func (Assertion) Equal

func (a Assertion) Equal(actual, expect interface{}, args ...interface{})

Equal assertian compares the type and value of actual and expect and when not equal will call fatal with:

Not equal:
  expect: {expect}
  actual: {actual} {args}

func (Assertion) Error

func (a Assertion) Error(err error, args ...interface{})

Error asserts that err is not nil, but if it is nil, it calls Fatal with:

An error is expected but got nil. {args}

func (Assertion) False

func (a Assertion) False(condition bool, args ...interface{})

False asserts that condition is false, when condition is true it calls Fatal with:

Unexpected {args}

func (Assertion) Must

func (a Assertion) Must(condition bool, args ...interface{})

Must asserts that condition is true, when it is false it calls Fatal with:

Must have {args}

func (Assertion) NoError

func (a Assertion) NoError(err error, args ...interface{})

NoError asserts that err must be nil, when it isn't it calls Fatal with:

No error was expected but got: {err}
{args}

func (Assertion) Not

func (a Assertion) Not(condition bool, args ...interface{})

Not asserts that condition is false, when condition is true it calls Fatal with:

Must not have {args}

func (Assertion) True

func (a Assertion) True(condition bool, args ...interface{})

True asserts that condition is true, when it is false it calls Fatal with:

Expected {args}

type T

type T struct {
	*testing.T
	// contains filtered or unexported fields
}

T is a struct embedding a *testing.T and therefore has the same methods as a testing.T type. It provides support for writing Test Driven Development (TDD) specs directly in Go. Is provides a domain-specific language patterned after RSpec https://en.wikipedia.org/wiki/RSpec.

Use it as follows:

func TestObservable_ConcatAll(e *testing.T) {
     Describ(e, "emits", func(t T) {
         Contex(t, "with a fast source", func(t T) {
             Contex(t, "and a slow concat", func(t T) {
                 I(t, "should complete before the first emit to observer", func(t T) {
                     Asser(t).NoError(nil)
                 })
             })
         })
     })
}

Directories

Path Synopsis
All determines whether all items emitted by an Observable meet some criteria.
All determines whether all items emitted by an Observable meet some criteria.
AsObservableBar when called on an Observable source will type assert the interface{} items of the source to bar items.
AsObservableBar when called on an Observable source will type assert the interface{} items of the source to bar items.
AsyncSubject emits the last value (and only the last value) emitted by the Observable part, and only after that Observable part completes.
AsyncSubject emits the last value (and only the last value) emitted by the Observable part, and only after that Observable part completes.
AuditTime waits until the source emits and then starts a timer.
AuditTime waits until the source emits and then starts a timer.
AutoConnect makes a Multicaster behave like an ordinary Observable that automatically connects the multicaster to its source when the specified number of observers have subscribed to it.
AutoConnect makes a Multicaster behave like an ordinary Observable that automatically connects the multicaster to its source when the specified number of observers have subscribed to it.
Average calculates the average of numbers emitted by an Observable and emits this average.
Average calculates the average of numbers emitted by an Observable and emits this average.
NewBehaviorSubject returns a new BehaviorSubject.
NewBehaviorSubject returns a new BehaviorSubject.
Buffer buffers the source Observable values until closingNotifier emits.
Buffer buffers the source Observable values until closingNotifier emits.
BufferTime buffers the source Observable values for a specific time period and emits those as a slice periodically in time.
BufferTime buffers the source Observable values for a specific time period and emits those as a slice periodically in time.
Catch recovers from an error notification by continuing the sequence without emitting the error but by switching to the catch ObservableInt to provide items.
Catch recovers from an error notification by continuing the sequence without emitting the error but by switching to the catch ObservableInt to provide items.
CatchError catches errors on the Observable to be handled by returning a new Observable or throwing an error.
CatchError catches errors on the Observable to be handled by returning a new Observable or throwing an error.
CombineLatest will subscribe to all Observables.
CombineLatest will subscribe to all Observables.
CombineLatestAll flattens a higher order observable (e.g.
CombineLatestAll flattens a higher order observable (e.g.
CombinesLatestMap maps every entry emitted by the Observable into an Observable, and then subscribe to it, until the source observable completes.
CombinesLatestMap maps every entry emitted by the Observable into an Observable, and then subscribe to it, until the source observable completes.
CombinesLatestMapTo maps every entry emitted by the Observable into a single Observable, and then subscribe to it, until the source observable completes.
CombinesLatestMapTo maps every entry emitted by the Observable into a single Observable, and then subscribe to it, until the source observable completes.
CombineLatestWith will subscribe to its Observable and all other Observables passed in.
CombineLatestWith will subscribe to its Observable and all other Observables passed in.
Concat emits the emissions from two or more observables without interleaving them.
Concat emits the emissions from two or more observables without interleaving them.
ConcatAll flattens a higher order observable by concattenating the observables it emits.
ConcatAll flattens a higher order observable by concattenating the observables it emits.
ConcatMap transforms the items emitted by an Observable by applying a function to each item and returning an Observable.
ConcatMap transforms the items emitted by an Observable by applying a function to each item and returning an Observable.
ConcatMapTo maps every entry emitted by the Observable into a single Observable.
ConcatMapTo maps every entry emitted by the Observable into a single Observable.
ConcatWith emits the emissions from two or more observables without interleaving them.
ConcatWith emits the emissions from two or more observables without interleaving them.
Connect instructs a connectable Observable to begin emitting items to its subscribers.
Connect instructs a connectable Observable to begin emitting items to its subscribers.
Count counts the number of items emitted by the source ObservableInt and emits only this value.
Count counts the number of items emitted by the source ObservableInt and emits only this value.
Create provides a way of creating an Observable from scratch by calling observer methods programmatically.
Create provides a way of creating an Observable from scratch by calling observer methods programmatically.
CreateFutureRecursive provides a way of creating an Observable from scratch by calling observer methods programmatically.
CreateFutureRecursive provides a way of creating an Observable from scratch by calling observer methods programmatically.
CreateRecursive provides a way of creating an Observable from scratch by calling observer methods programmatically.
CreateRecursive provides a way of creating an Observable from scratch by calling observer methods programmatically.
DebounceTime only emits the last item of a burst from an Observable if a particular timespan has passed without it emitting another item.
DebounceTime only emits the last item of a burst from an Observable if a particular timespan has passed without it emitting another item.
Defer does not create the Observable until the observer subscribes.
Defer does not create the Observable until the observer subscribes.
Delay shifts the emission from an Observable forward in time by a particular amount of time.
Delay shifts the emission from an Observable forward in time by a particular amount of time.
Distinct suppress duplicate items emitted by an Observable.
Distinct suppress duplicate items emitted by an Observable.
DistinctUntilChanged only emits when the current value is different from the last.
DistinctUntilChanged only emits when the current value is different from the last.
Do calls a function for each next value passing through the observable.
Do calls a function for each next value passing through the observable.
DoOnComplete calls a function when the stream completes.
DoOnComplete calls a function when the stream completes.
DoOnError calls a function for any error on the stream.
DoOnError calls a function for any error on the stream.
ElementAt emit only item n emitted by an Observable.
ElementAt emit only item n emitted by an Observable.
Empty creates an Observable that emits no items but terminates normally.
Empty creates an Observable that emits no items but terminates normally.
Filter emits only those items from an observable that pass a predicate test.
Filter emits only those items from an observable that pass a predicate test.
Finally applies a function for any error or completion on the stream.
Finally applies a function for any error or completion on the stream.
First emits only the first item, or the first item that meets a condition, from an Observable.
First emits only the first item, or the first item that meets a condition, from an Observable.
From creates an observable from multiple values passed in.
From creates an observable from multiple values passed in.
FromChan creates an Observable from a Go channel.
FromChan creates an Observable from a Go channel.
IgnoreCompletion only emits items and never completes, neither with Error nor with Complete.
IgnoreCompletion only emits items and never completes, neither with Error nor with Complete.
IgnoreElements does not emit any items from an Observable but mirrors its termination notification.
IgnoreElements does not emit any items from an Observable but mirrors its termination notification.
Interval creates an ObservableInt that emits a sequence of integers spaced by a particular time interval.
Interval creates an ObservableInt that emits a sequence of integers spaced by a particular time interval.
Just creates an observable that emits a particular item.
Just creates an observable that emits a particular item.
Last emits only the last item emitted by an Observable.
Last emits only the last item emitted by an Observable.
Map transforms the items emitted by an Observable by applying a function to each item.
Map transforms the items emitted by an Observable by applying a function to each item.
MapTo transforms the items emitted by an Observable.
MapTo transforms the items emitted by an Observable.
Max determines, and emits, the maximum-valued item emitted by an Observable.
Max determines, and emits, the maximum-valued item emitted by an Observable.
Merge combines multiple Observables into one by merging their emissions.
Merge combines multiple Observables into one by merging their emissions.
MergeAll flattens a higher order observable by merging the observables it emits.
MergeAll flattens a higher order observable by merging the observables it emits.
MergeDelayError combines multiple Observables into one by merging their emissions.
MergeDelayError combines multiple Observables into one by merging their emissions.
MergeDelayErrorWith combines multiple Observables into one by merging their emissions.
MergeDelayErrorWith combines multiple Observables into one by merging their emissions.
MergeMap transforms the items emitted by an Observable by applying a function to each item an returning an Observable.
MergeMap transforms the items emitted by an Observable by applying a function to each item an returning an Observable.
MergeMapTo maps every entry emitted by the Observable into a single Observable.
MergeMapTo maps every entry emitted by the Observable into a single Observable.
MergeWith combines multiple Observables into one by merging their emissions.
MergeWith combines multiple Observables into one by merging their emissions.
Min determines, and emits, the minimum-valued item emitted by an Observable.
Min determines, and emits, the minimum-valued item emitted by an Observable.
Never creates an Observable that emits no items and does't terminate.
Never creates an Observable that emits no items and does't terminate.
Observable is essentially a subscribe function taking an observe function, scheduler and an subscriber.
Observable is essentially a subscribe function taking an observe function, scheduler and an subscriber.
ObserveOn specifies a schedule function to use for delivering values to the observer.
ObserveOn specifies a schedule function to use for delivering values to the observer.
ObserverObservable actually is an observer that is made observable.
ObserverObservable actually is an observer that is made observable.
Of emits a variable amount of values in a sequence and then emits a complete notification.
Of emits a variable amount of values in a sequence and then emits a complete notification.
Only filters the value stream of an observable and lets only the values of a specific type pass.
Only filters the value stream of an observable and lets only the values of a specific type pass.
Passthrough just passes through all output from the Observable.
Passthrough just passes through all output from the Observable.
Println subscribes to the Observable and prints every item to os.Stdout while it waits for completion or error.
Println subscribes to the Observable and prints every item to os.Stdout while it waits for completion or error.
Publish returns a Multicaster for a Subject to an underlying Observable and turns the subject into a connnectable observable.
Publish returns a Multicaster for a Subject to an underlying Observable and turns the subject into a connnectable observable.
PublishBehavior returns a Multicaster that shares a single subscription to the underlying Observable returning an initial value or the last value emitted by the underlying Observable.
PublishBehavior returns a Multicaster that shares a single subscription to the underlying Observable returning an initial value or the last value emitted by the underlying Observable.
PublishLast returns a Multicaster that shares a single subscription to the underlying Observable containing only the last value emitted before it completes.
PublishLast returns a Multicaster that shares a single subscription to the underlying Observable containing only the last value emitted before it completes.
PublishReplay returns a Multicaster for a ReplaySubject to an underlying Observable and turns the subject into a connectable observable.
PublishReplay returns a Multicaster for a ReplaySubject to an underlying Observable and turns the subject into a connectable observable.
Range creates an Observable that emits a range of sequential int values.
Range creates an Observable that emits a range of sequential int values.
Reduce applies a reducer function to each item emitted by an Observable and the previous reducer result.
Reduce applies a reducer function to each item emitted by an Observable and the previous reducer result.
RefCount makes a Connectable behave like an ordinary Observable.
RefCount makes a Connectable behave like an ordinary Observable.
Repeat creates an observable that emits a sequence of items repeatedly.
Repeat creates an observable that emits a sequence of items repeatedly.
ReplaySubject ensures that all observers see the same sequence of emitted items, even if they subscribe after.
ReplaySubject ensures that all observers see the same sequence of emitted items, even if they subscribe after.
Retry if a source Observable sends an error notification, resubscribe to it in the hopes that it will complete without error.
Retry if a source Observable sends an error notification, resubscribe to it in the hopes that it will complete without error.
SampleTime emits the most recent item emitted by an Observable within periodic time intervals.
SampleTime emits the most recent item emitted by an Observable within periodic time intervals.
Scan applies a accumulator function to each item emitted by an Observable and the previous accumulator result.
Scan applies a accumulator function to each item emitted by an Observable and the previous accumulator result.
Serialize forces an observable to make serialized calls and to be well-behaved.
Serialize forces an observable to make serialized calls and to be well-behaved.
Single enforces that the observable sends exactly one data item and then completes.
Single enforces that the observable sends exactly one data item and then completes.
Skip suppresses the first n items emitted by an Observable.
Skip suppresses the first n items emitted by an Observable.
SkipLast suppresses the last n items emitted by an Observable.
SkipLast suppresses the last n items emitted by an Observable.
Start creates an Observable that emits the return value of a function.
Start creates an Observable that emits the return value of a function.
StartWith returns an observable that, at the moment of subscription, will synchronously emit all values provided to this operator, then subscribe to the source and mirror all of its emissions to subscribers.
StartWith returns an observable that, at the moment of subscription, will synchronously emit all values provided to this operator, then subscribe to the source and mirror all of its emissions to subscribers.
Subject is a combination of an observer and observable.
Subject is a combination of an observer and observable.
Subscribe operates upon the emissions and notifications from an Observable.
Subscribe operates upon the emissions and notifications from an Observable.
SubscribeOn specifies the scheduler an Observable should use when it is subscribed to.
SubscribeOn specifies the scheduler an Observable should use when it is subscribed to.
Sum calculates the sum of numbers emitted by an Observable and emits this sum.
Sum calculates the sum of numbers emitted by an Observable and emits this sum.
SwitchAll converts an Observable that emits Observables into a single Observable that emits the items emitted by the most-recently-emitted of those Observables.
SwitchAll converts an Observable that emits Observables into a single Observable that emits the items emitted by the most-recently-emitted of those Observables.
SwitchMap transforms the items emitted by an Observable by applying a function to each item an returning an Observable.
SwitchMap transforms the items emitted by an Observable by applying a function to each item an returning an Observable.
Take emits only the first n items emitted by an Observable.
Take emits only the first n items emitted by an Observable.
TakeLast emits only the last n items emitted by an Observable.
TakeLast emits only the last n items emitted by an Observable.
TakeUntil emits items emitted by an Observable until another Observable emits an item.
TakeUntil emits items emitted by an Observable until another Observable emits an item.
TakeWhile mirrors items emitted by an Observable until a specified condition becomes false.
TakeWhile mirrors items emitted by an Observable until a specified condition becomes false.
ThrottleTime emits when the source emits and then starts a timer during which all emissions from the source are ignored.
ThrottleTime emits when the source emits and then starts a timer during which all emissions from the source are ignored.
Throw creates an observable that emits no items and terminates with an error.
Throw creates an observable that emits no items and terminates with an error.
Ticker creates an ObservableTime that emits a sequence of timestamps after an initialDelay has passed.
Ticker creates an ObservableTime that emits a sequence of timestamps after an initialDelay has passed.
TimeInterval intercepts the items from the source Observable and emits in their place a struct that indicates the amount of time that elapsed between pairs of emissions.
TimeInterval intercepts the items from the source Observable and emits in their place a struct that indicates the amount of time that elapsed between pairs of emissions.
Timeout mirrors the source Observable, but issue an error notification if a particular period of time elapses without any emitted items.
Timeout mirrors the source Observable, but issue an error notification if a particular period of time elapses without any emitted items.
Timer creates an Observable that emits a sequence of integers (starting at zero) after an initialDelay has passed.
Timer creates an Observable that emits a sequence of integers (starting at zero) after an initialDelay has passed.
Timestamp attaches a timestamp to each item emitted by an observable indicating when it was emitted.
Timestamp attaches a timestamp to each item emitted by an observable indicating when it was emitted.
ToChan returns a channel that emits interface{} values.
ToChan returns a channel that emits interface{} values.
ToSingle blocks until the Observable emits exactly one value or an error.
ToSingle blocks until the Observable emits exactly one value or an error.
ToSlice collects all values from the Observable into an slice.
ToSlice collects all values from the Observable into an slice.
Wait subscribes to the Observable and waits for completion or error.
Wait subscribes to the Observable and waits for completion or error.
WithLatestFrom will subscribe to all Observables and wait for all of them to emit before emitting the first slice.
WithLatestFrom will subscribe to all Observables and wait for all of them to emit before emitting the first slice.
WithLatestFromAll flattens a higher order observable (e.g.
WithLatestFromAll flattens a higher order observable (e.g.

Jump to

Keyboard shortcuts

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