Documentation
¶
Overview ¶
Package output provides utilities for testing barista outputs and segments.
Index ¶
- type Assertions
- func (a Assertions) AssertEmpty(args ...interface{})
- func (a Assertions) AssertEqual(expected bar.Output, args ...interface{})
- func (a Assertions) AssertError(args ...interface{}) []string
- func (a Assertions) AssertText(expected []string, args ...interface{})
- func (a Assertions) At(i int) SegmentAssertions
- func (a Assertions) Expect(args ...interface{})
- func (a Assertions) Len() int
- type SegmentAssertions
- func (a SegmentAssertions) AssertEqual(expected *bar.Segment, args ...interface{})
- func (a SegmentAssertions) AssertError(args ...interface{}) string
- func (a SegmentAssertions) AssertText(expected string, args ...interface{})
- func (a SegmentAssertions) Click(e bar.Event)
- func (a SegmentAssertions) LeftClick()
- func (a SegmentAssertions) Segment() *bar.Segment
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Assertions ¶
type Assertions struct {
// contains filtered or unexported fields
}
Assertions provides assertions that simplify testing outputs.
func New ¶
func New(t require.TestingT, out bar.Output) Assertions
New creates an object that provides assertions on a bar.Output, such as equality, emptiness, text equality, and error state across all its segments.
func (Assertions) AssertEmpty ¶
func (a Assertions) AssertEmpty(args ...interface{})
AssertEmpty asserts that the actual output has no segments.
func (Assertions) AssertEqual ¶
func (a Assertions) AssertEqual(expected bar.Output, args ...interface{})
AssertEqual asserts that the actual output contains exactly the same segments as the expected output.
func (Assertions) AssertError ¶
func (a Assertions) AssertError(args ...interface{}) []string
AssertError asserts that each segment in the output is an error, and returns a slice containing the error descriptions.
func (Assertions) AssertText ¶
func (a Assertions) AssertText(expected []string, args ...interface{})
AssertText asserts that the text of each segment matches the expected value.
func (Assertions) At ¶
func (a Assertions) At(i int) SegmentAssertions
At creates segment assertions for the segment at position i. It fails the test if there are not enough segments.
func (Assertions) Expect ¶
func (a Assertions) Expect(args ...interface{})
Expect asserts that the output is not nil. Used in a chain, e.g. testBar.NextOutput().Expect("expected an output")
func (Assertions) Len ¶
func (a Assertions) Len() int
Len returns the number of segments in the actual output.
type SegmentAssertions ¶
type SegmentAssertions struct {
// contains filtered or unexported fields
}
SegmentAssertions provides assertions that simplify testing individual segments within an output.
func Segment ¶
func Segment(t require.TestingT, segment *bar.Segment) SegmentAssertions
Segment provides text, error, and equality assertions for a bar.Segment
func (SegmentAssertions) AssertEqual ¶
func (a SegmentAssertions) AssertEqual(expected *bar.Segment, args ...interface{})
AssertEqual asserts that the actual segment is equal to the expecte segment.
func (SegmentAssertions) AssertError ¶
func (a SegmentAssertions) AssertError(args ...interface{}) string
AssertError asserts that the segment represents an error, and returns the error description.
func (SegmentAssertions) AssertText ¶
func (a SegmentAssertions) AssertText(expected string, args ...interface{})
AssertText asserts that the segment's text matches the expected string.
func (SegmentAssertions) Click ¶
func (a SegmentAssertions) Click(e bar.Event)
Click clicks on the segment. Because it's provided on SegmentAssertions, it automatically ensures that the expected segment is present. e.g. testBar.NextOutput().At(2).Click(...).
func (SegmentAssertions) LeftClick ¶
func (a SegmentAssertions) LeftClick()
LeftClick is a convenience wrapper since left-clicking is a common operation.
func (SegmentAssertions) Segment ¶
func (a SegmentAssertions) Segment() *bar.Segment
Segment returns the actual segment to allow fine-grained assertions. This is doubly useful because Assertions.At(i) returns SegmentAssertions, allowing code like:
urgent, _ := out.At(2).Segment().IsUrgent() require.True(t, urgent, "segment #3 is urgent")