outputs

package
v0.16.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckFormatOptions added in v0.15.3

func CheckFormatOptions(format string, opts []string) (unknown, ignored []string)

CheckFormatOptions sorts opts against format. Names are matched without regard to case, as the formats themselves match them, and after NormalizeFormatOptions.

unknown holds options no format knows; ignored holds options some other format knows but this one does not honour. Neither is an error: both have always been accepted and had no effect, so the caller warns rather than refusing to run. ignored is empty for an unknown format, which GetOutputer reports. Each name is reported once, under its first spelling, however often and in whatever case it was repeated.

func FormatOptions

func FormatOptions() []string

FormatOptions returns a sorted list of every option at least one format accepts.

func IsValidFormat

func IsValidFormat(f string) bool

IsValidFormat determines if f is a valid format name based on Outputers()

func MetricsRegistry

func MetricsRegistry(outConfig util.OutputConfig) *prometheus.Registry

MetricsRegistry returns the private registry that the prometheus outputter records into, initialising it if it does not exist yet.

It exists so `serve`'s /metrics endpoint can expose the same metrics the prometheus output format produces. Previously serve.go handed /metrics the default global registry, which these metrics are never registered into (they go into the private registry created below), so /metrics could only ever return zero occurrences of goss_tests_outcomes_total.

Note the label cardinality is fixed by whichever caller initialises the registry first — the same first-call-wins behaviour Output() already had. Callers should pass the process-level OutputConfig so this is deterministic.

func NormalizeFormatOptions added in v0.15.3

func NormalizeFormatOptions(opts []string) []string

NormalizeFormatOptions trims surrounding whitespace from each option and drops any left empty, so "pretty, sort" from an environment variable means the same as -o pretty -o sort. The formats compare option names exactly apart from case, so an untrimmed " sort" would otherwise be ignored.

func Outputers

func Outputers() []string

Outputers returns a sorted list of the names of the registered outputers.

func ValidOptionsFor added in v0.15.3

func ValidOptionsFor(format string) []string

ValidOptionsFor returns the sorted options the named format honours, or nil if format is not a format name.

Types

type Discovery

type Discovery struct{}

func (Discovery) Output

func (r Discovery) Output(w io.Writer, discovered map[string]bool, outConfig util.OutputConfig) int

func (Discovery) ValidOptions

func (r Discovery) ValidOptions() []*formatOption

ValidOptions is a list of valid format options for discovery output.

type Documentation

type Documentation struct{}

func (Documentation) Output

func (r Documentation) Output(w io.Writer, results <-chan []resource.TestResult,
	outConfig util.OutputConfig) (exitCode int)

func (Documentation) ValidOptions

func (r Documentation) ValidOptions() []*formatOption

type JUnit

type JUnit struct{}

func (JUnit) Output

func (r JUnit) Output(w io.Writer, results <-chan []resource.TestResult,
	outConfig util.OutputConfig) (exitCode int)

func (JUnit) ValidOptions

func (r JUnit) ValidOptions() []*formatOption

type Json

type Json struct{}

func (Json) Output

func (r Json) Output(w io.Writer, results <-chan []resource.TestResult,
	outConfig util.OutputConfig) (exitCode int)

func (Json) ValidOptions

func (r Json) ValidOptions() []*formatOption

type Nagios

type Nagios struct{}

func (Nagios) Output

func (r Nagios) Output(w io.Writer, results <-chan []resource.TestResult,
	outConfig util.OutputConfig) (exitCode int)

func (Nagios) ValidOptions

func (r Nagios) ValidOptions() []*formatOption

type Outputer

type Outputer interface {
	Output(io.Writer, <-chan []resource.TestResult, util.OutputConfig) int
	ValidOptions() []*formatOption
}

func GetOutputer

func GetOutputer(name string) (Outputer, error)

type Prometheus

type Prometheus struct{}

Prometheus renders metrics in prometheus.io text-format https://prometheus.io/docs/instrumenting/exposition_formats/#text-based-format

func (Prometheus) Output

func (r Prometheus) Output(w io.Writer, results <-chan []resource.TestResult,
	outConfig util.OutputConfig) (exitCode int)

Output converts the results into the prometheus text-format.

func (Prometheus) ValidOptions

func (r Prometheus) ValidOptions() []*formatOption

ValidOptions is a list of valid format options for prometheus

type Rspecish

type Rspecish struct{}

func (Rspecish) Output

func (r Rspecish) Output(w io.Writer, results <-chan []resource.TestResult,
	outConfig util.OutputConfig) (exitCode int)

func (Rspecish) ValidOptions

func (r Rspecish) ValidOptions() []*formatOption

type Silent

type Silent struct{}

func (Silent) Output

func (r Silent) Output(w io.Writer, results <-chan []resource.TestResult,
	outConfig util.OutputConfig) (exitCode int)

func (Silent) ValidOptions

func (r Silent) ValidOptions() []*formatOption

type StructureTestSummary

type StructureTestSummary struct {
	TestCount     int           `json:"test-count"`
	Failed        int           `json:"failed-count"`
	TotalDuration time.Duration `json:"total-duration"`
}

StructureTestSummary holds summary information about a test run

func (*StructureTestSummary) String

func (s *StructureTestSummary) String() string

String represents human friendly representation of the test summary

type Structured

type Structured struct{}

Structured is a output formatter that logs into a StructuredOutput structure

func (Structured) Output

func (r Structured) Output(w io.Writer, results <-chan []resource.TestResult, outConfig util.OutputConfig) (exitCode int)

Output processes output from tests into StructuredOutput written to w as a string

func (Structured) ValidOptions

func (r Structured) ValidOptions() []*formatOption

type StructuredOutput

type StructuredOutput struct {
	Results     []StructuredTestResult `json:"results"`
	Summary     StructureTestSummary   `json:"summary"`
	SummaryLine string                 `json:"summary-line"`
}

StructuredOutput is the full output structure for the structured output format

type StructuredTestResult

type StructuredTestResult struct {
	resource.TestResult
	SummaryLine        string `json:"summary-line"`
	SummaryLineCompact string `json:"summary-line-compact"`
}

StructuredTestResult is an individual test result with additional human friendly summary

type Tap

type Tap struct{}

func (Tap) Output

func (r Tap) Output(w io.Writer, results <-chan []resource.TestResult,
	outConfig util.OutputConfig) (exitCode int)

func (Tap) ValidOptions

func (r Tap) ValidOptions() []*formatOption

Jump to

Keyboard shortcuts

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