barista.run: barista.run/testing/output Index | Files

package output

import "barista.run/testing/output"

Package output provides utilities for testing barista outputs and segments.

Index

Package Files

output.go

type Assertions Uses

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

Assertions provides assertions that simplify testing outputs.

func New Uses

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 Uses

func (a Assertions) AssertEmpty(args ...interface{})

AssertEmpty asserts that the actual output has no segments.

func (Assertions) AssertEqual Uses

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 Uses

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 Uses

func (a Assertions) AssertText(expected []string, args ...interface{})

AssertText asserts that the text of each segment matches the expected value.

func (Assertions) At Uses

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 Uses

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 Uses

func (a Assertions) Len() int

Len returns the number of segments in the actual output.

type SegmentAssertions Uses

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

SegmentAssertions provides assertions that simplify testing individual segments within an output.

func Segment Uses

func Segment(t require.TestingT, segment *bar.Segment) SegmentAssertions

Segment provides text, error, and equality assertions for a bar.Segment

func (SegmentAssertions) AssertEqual Uses

func (a SegmentAssertions) AssertEqual(expected *bar.Segment, args ...interface{})

AssertEqual asserts that the actual segment is equal to the expecte segment.

func (SegmentAssertions) AssertError Uses

func (a SegmentAssertions) AssertError(args ...interface{}) string

AssertError asserts that the segment represents an error, and returns the error description.

func (SegmentAssertions) AssertText Uses

func (a SegmentAssertions) AssertText(expected string, args ...interface{})

AssertText asserts that the segment's text matches the expected string.

func (SegmentAssertions) Click Uses

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 Uses

func (a SegmentAssertions) LeftClick()

LeftClick is a convenience wrapper since left-clicking is a common operation.

func (SegmentAssertions) Segment Uses

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

Package output imports 2 packages (graph) and is imported by 1 packages. Updated 2018-09-03. Refresh now. Tools for package owners.