expectations

package
v0.0.0-...-7d312d8 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2024 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Untriaged represents a previously unseen digest.
	Untriaged = Label("untriaged")

	// Positive represents a known good digest
	Positive = Label("positive")

	// Negative represents a known bad digest.
	Negative = Label("negative")
)

Variables

AllLabel is a list of all possible Label values. The index of each element in this list must match its LabelInt value (Untriaged = 0, etc.).

Functions

func ValidLabel

func ValidLabel(s Label) bool

ValidLabel returns true if the given Label is valid.

Types

type Baseline

type Baseline map[types.TestName]map[types.Digest]Label

Baseline is a simplified view of the Expectations, suitable for JSON encoding. A Baseline only has entries with positive and negative labels (i.e. no untriaged entries).

type Classifier

type Classifier interface {
	// Classification returns the label for the given test/digest pair. By definition,
	// this will return Untriaged if there isn't already a classification set.
	Classification(test types.TestName, digest types.Digest) Label
}

Classifier is a simple interface for querying expectations.

func EmptyClassifier

func EmptyClassifier() Classifier

EmptyClassifier returns a Classifier which returns Untriaged for given input. Mostly used for testing.

type Expectations

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

Expectations captures the expectations for a set of tests and digests as labels (Positive/Negative/Untriaged). Put another way, this data structure keeps track if a digest (image) is drawn correctly, incorrectly, or newly-seen for a given test. Expectations is thread safe.

func (*Expectations) AsBaseline

func (e *Expectations) AsBaseline() Baseline

AsBaseline returns a copy that has all untriaged digests removed.

func (*Expectations) Classification

func (e *Expectations) Classification(test types.TestName, digest types.Digest) Label

Classification implements the ReadOnly interface.

func (*Expectations) DeepCopy

func (e *Expectations) DeepCopy() *Expectations

DeepCopy makes a deep copy of the current expectations/baseline.

func (*Expectations) Empty

func (e *Expectations) Empty() bool

Empty implements the ReadOnly interface.

func (*Expectations) ForAll

func (e *Expectations) ForAll(fn func(types.TestName, types.Digest, Label) error) error

ForAll implements the ReadOnly interface.

func (*Expectations) Len

func (e *Expectations) Len() int

Len implements the ReadOnly interface.

func (*Expectations) MergeExpectations

func (e *Expectations) MergeExpectations(other *Expectations)

MergeExpectations adds the given expectations to the current expectations, letting the ones provided by the passed in parameter overwrite any existing data. Trying to merge two expectations into each other simultaneously may result in a dead-lock.

func (*Expectations) NumTests

func (e *Expectations) NumTests() int

NumTests implements the ReadOnly interface.

func (*Expectations) Set

func (e *Expectations) Set(testName types.TestName, digest types.Digest, label Label)

Set sets the label for a test_name/digest pair. If the pair already exists, it will be over written.

func (*Expectations) String

func (e *Expectations) String() string

String returns an alphabetically sorted string representation of this object.

type JoinedExp

type JoinedExp []ReadOnly

JoinedExp represents a chain of ReadOnly that could contain Labels. The Expectations at the beginning of the list override those that follow.

func Join

func Join(first, second ReadOnly, others ...ReadOnly) JoinedExp

Join returns a Classifier that combines the given ReadOnly. If multiple ReadOnly have a Label for a given Grouping (Test+Digest), the order of the ReadOnly will break the tie by using the ReadOnly which was provided first.

func (JoinedExp) Classification

func (e JoinedExp) Classification(test types.TestName, digest types.Digest) Label

Classification returns the first non-untriaged label for the given test and digest. If none of the given ReadOnly have a match, Untriaged is returned.

type Label

type Label string

Label represents a digest classification.

type ReadOnly

type ReadOnly interface {
	Classifier
	// ForAll will iterate through all entries in Expectations and call the callback with them.
	// Iteration will stop if a non-nil error is returned (and will be forwarded to the caller).
	ForAll(fn func(types.TestName, types.Digest, Label) error) error

	// Empty returns true iff NumTests() == 0
	Empty() bool

	// NumTests returns the number of tests that Expectations knows about.
	NumTests() int

	// Len returns the number of test/digest pairs stored.
	Len() int
}

ReadOnly is an interface with the non-mutating functions of Expectations. By using this instead of Expectations, we can make fewer copies, helping performance.

Jump to

Keyboard shortcuts

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