llbtest

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContainsNFileActions

func ContainsNFileActions[T any](t *testing.T, fileOp *pb.Op_File, n int, msg string) ([]*pb.FileAction, []T)

ContainsNFileActions requires that there are exactly n pb.FileAction within the pb.Op_File that are of the given type. If successful, the matching pb.FileAction and encapsulated pb.FileAction.Action field of the given type are returned.

func ContainsNOps

func ContainsNOps[T any](t *testing.T, ops []pb.Op, n int, msg string) ([]pb.Op, []T)

ContainsNOps requires that there are exactly n pb.Op that are of the given type. If successful, the matching pb.Op and encapsulated pb.Op.Op field of the given type are returned.

func HasValidInputs

func HasValidInputs(t *testing.T, opMap map[digest.Digest]pb.Op, op pb.Op) []pb.Op

HasValidInputs takes a pb.Op and asserts that all of its pb.Op.Inputs have a corresponding pb.Op in the given op map. If the assertion succeeds, each corresponding pb.Op is returned.

func LastOp

func LastOp(t *testing.T, arr []pb.Op) (digest.Digest, int)

LastOp returns the final Op in the given ordered slice

func ParseDef

func ParseDef(t *testing.T, def [][]byte) (map[digest.Digest]pb.Op, []pb.Op)

ParseDef parses the given llb.Definition in a pb.Op slice and map of digest.Digest to ops.

Types

type Assertions

type Assertions struct {
	*require.Assertions
	// contains filtered or unexported fields
}

Assertions provides methods for making assertions on LLB build graphs, specifically the marshaled llb.Definition and pb.Op therein. It extends require.Assertions to provide a singular assertions interface in LLB related tests.

func New

func New(t *testing.T, def *llb.Definition) *Assertions

New returns a new Assertions that encapsulates the testing.T and llb.Definition for ease of making many assertions about the contained op.

func (*Assertions) ContainsNCopyActions

func (llbt *Assertions) ContainsNCopyActions(fileOp *pb.Op_File, n int) ([]*pb.FileAction, []*pb.FileAction_Copy)

ContainsNCopyActions is a convenience method for ContainsNFileActions[pb.FileAction_Copy](...)

func (*Assertions) ContainsNExecOps

func (llbt *Assertions) ContainsNExecOps(n int) ([]pb.Op, []*pb.Op_Exec)

ContainsNExecOps is a convenience method for ContainsNOps[pb.Op_Exec](...)

func (*Assertions) ContainsNFileOps

func (llbt *Assertions) ContainsNFileOps(n int) ([]pb.Op, []*pb.Op_File)

ContainsNFileOps is a convenience method for ContainsNOps[pb.Op_File](...)

func (*Assertions) ContainsNSourceOps

func (llbt *Assertions) ContainsNSourceOps(n int) ([]pb.Op, []*pb.Op_Source)

ContainsNSourceOps is a convenience method for ContainsNOps[pb.Op_Source](...)

func (*Assertions) HasCustomName added in v1.0.0

func (llbt *Assertions) HasCustomName(name string, op pb.Op)

HasCustomName asserts that the given pb.Op has an "llb.customname" description in its pb.OpMetadata matching the given string.

func (*Assertions) HasDescription added in v1.0.0

func (llbt *Assertions) HasDescription(key string, op pb.Op) string

HasDescription asserts that the given pb.Op has the given description key in its pb.OpMetadata. If the assertion succeeds, the description value is returned.

func (*Assertions) HasOpMetadata added in v1.0.0

func (llbt *Assertions) HasOpMetadata(op pb.Op) pb.OpMetadata

HasOpMetadata asserts that the given pb.Op has pb.OpMetadata in the given llb.Definition. If the assertion succeeds, the pb.OpMetadata is returned.

func (*Assertions) HasValidInputs

func (llbt *Assertions) HasValidInputs(op pb.Op) []pb.Op

HasValidInputs is a convenience method for HasValidInputs

Jump to

Keyboard shortcuts

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