llbtest

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: GPL-3.0 Imports: 7 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 HasMetadata

func HasMetadata(t *testing.T, metadata map[digest.Digest]llb.OpMetadata, op *pb.Op) llb.OpMetadata

HasMetadata takes a pb.Op and asserts that it has an entry in the definition metadata. The corresponding llb.OpMetadata is returned.

func HasValidInputs

func HasValidInputs(t *testing.T, opMap map[string]*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 ParseDef

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

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

func ParseState

func ParseState(t *testing.T, state llb.State) (map[string]*pb.Op, []*pb.Op)

ParseState marshals the given llb.State to a llb.Definition, then parses it as a pb.Op slice and map of digests 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) ContainsNDiffOps

func (llbt *Assertions) ContainsNDiffOps(n int) ([]*pb.Op, []*pb.Op_Diff)

ContainsNDiffOps is a convenience method for ContainsNOps[pb.Op_Diff](...)

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

func (llbt *Assertions) ContainsNMergeOps(n int) ([]*pb.Op, []*pb.Op_Merge)

ContainsNMergeOps is a convenience method for ContainsNOps[pb.Op_Merge](...)

func (*Assertions) ContainsNMkdirActions

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

ContainsNMkdirActions is a convenience method for ContainsNFileActions[pb.FileAction_Mkdir](...)

func (*Assertions) ContainsNMkfileActions

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

ContainsNMkfileActions is a convenience method for ContainsNFileActions[pb.FileAction_Mkfile](...)

func (*Assertions) ContainsNOps

func (llbt *Assertions) ContainsNOps(n int) []*pb.Op

ContainsNOps is a convenience method for ContainsNOps[any](...)

func (*Assertions) ContainsNRmActions

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

ContainsNRmActions is a convenience method for ContainsNFileActions[pb.FileAction_Rm](...)

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

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

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

func (llbt *Assertions) HasMetadata(op *pb.Op) llb.OpMetadata

HasMetadata is a convenience method for HasMetadata

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
JackTT - Gopher 🇻🇳