output

package
v0.0.0-...-c936f35 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: Apache-2.0 Imports: 2 Imported by: 1

Documentation

Overview

Package output provides utilities for testing barista outputs and segments.

Index

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

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

Jump to

Keyboard shortcuts

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