fixturez

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 14 Imported by: 4

Documentation

Overview

Package fixturez provides a test suite framework and various utilities for capturing output.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MustBeginOutputCapture

func MustBeginOutputCapture(outputSetupFuncs ...OutputSetupFunc)

MustBeginOutputCapture sets up the mock streams and starts capturing the output. It panics if another output capture is already in progress. It is the caller's responsibility to ensure mutual exclusion.

func MustEndOutputCapture

func MustEndOutputCapture() (string, string)

MustEndOutputCapture restores the real streams and returns the captured data. It panics if no output capture is in progress.

func ResetOutputCapture

func ResetOutputCapture()

ResetOutputCapture ensures the output capture is cleared and reset (e.g. after a panic, error or test assertion that prevents MustEndOutputCapture from being called). Always defer ResetOutputCapture before using output captures.

func RunSuite

func RunSuite(t *testing.T, suite any)

RunSuite runs the test suite.

Types

type AfterSuite

type AfterSuite interface {
	AfterSuite(context.Context, *gomega.WithT)
}

AfterSuite represents a method invoked after completing a test suite.

type AfterTest

type AfterTest interface {
	AfterTest(context.Context, *gomega.WithT)
}

AfterTest represents a method invoked after each test method in a suite.

type BeforeSuite

type BeforeSuite interface {
	BeforeSuite(context.Context, *gomega.WithT) context.Context
}

BeforeSuite describes a method invoked before starting a test suite.

type BeforeTest

type BeforeTest interface {
	BeforeTest(context.Context, *gomega.WithT, *gomock.Controller) context.Context
}

BeforeTest represents a method invoked before each test method in a suite.

type OutputRestoreFunc

type OutputRestoreFunc func()

OutputRestoreFunc describe a function that restores some real streams after capturing.

func OutputSetupRodaineTable

func OutputSetupRodaineTable(outW *os.File, _ *os.File) OutputRestoreFunc

OutputSetupRodaineTable is a OutputSetupFunc that configures the table streams (from "github.com/rodaine/table").

func OutputSetupStandard

func OutputSetupStandard(outW *os.File, errW *os.File) OutputRestoreFunc

OutputSetupStandard is a OutputSetupFunc that configures the stdout/stderr streams.

type OutputSetupFunc

type OutputSetupFunc func(outW *os.File, errW *os.File) OutputRestoreFunc

OutputSetupFunc describes a function that replaces some streams with mock ones for capturing.

func GetOutputSetupFatihColor

func GetOutputSetupFatihColor(noColor bool) OutputSetupFunc

GetOutputSetupFatihColor returns a OutputSetupFunc that configures the color streams (from "github.com/fatih/color").

Jump to

Keyboard shortcuts

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