graphtest

package
v0.7.2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddElement

func AddElement(t *testing.T, g construct.Graph, e any) (failed bool)

AddElement is a utility function for adding an element to a graph. See MakeGraph for more information on supported element types. Returns whether adding the element failed.

func AssertGraphContains

func AssertGraphContains(t *testing.T, expect, actual construct.Graph)

func AssertGraphEqual

func AssertGraphEqual(t *testing.T, expect, actual construct.Graph, message string, args ...any)

func MakeGraph

func MakeGraph(t *testing.T, g construct.Graph, elements ...any) construct.Graph

MakeGraph is a utility function for creating a graph from a list of elements which can be of types: - ResourceId : adds an empty resource with the given ID - Resource, *Resource : adds the given resource - Edge : adds the given edge - Path : adds all the edges in the path - string : parses the string as either a ResourceId or an Edge and add it as above

The input graph is so it can be either via NewGraph or NewAcyclicGraph. Users are encouraged to wrap this function for the specific test function for ease of use, such as:

makeGraph := func(elements ...any) Graph {
	return MakeGraph(t, NewGraph(), elements...)
}

func ParseEdge

func ParseEdge(t *testing.T, str string) construct.Edge

func ParseId

func ParseId(t *testing.T, str string) (id construct.ResourceId)

func ParsePath

func ParsePath(t *testing.T, str string) construct.Path

func ParseRef

func ParseRef(t *testing.T, str string) construct.PropertyRef

func StringToGraphElement

func StringToGraphElement(e string) (any, error)

Types

type GraphChanges

type GraphChanges struct {
	construct.Graph

	Added   []construct.ResourceId
	Removed []construct.ResourceId

	AddedEdges   []construct.Edge
	RemovedEdges []construct.Edge
}

func RecordChanges

func RecordChanges(inner construct.Graph) *GraphChanges

func (*GraphChanges) AddEdge

func (c *GraphChanges) AddEdge(
	sourceHash, targetHash construct.ResourceId,
	options ...func(*graph.EdgeProperties),
) error

func (*GraphChanges) AddEdgesFrom

func (c *GraphChanges) AddEdgesFrom(g construct.Graph) error

func (*GraphChanges) AddVertex

func (c *GraphChanges) AddVertex(value *construct.Resource, options ...func(*graph.VertexProperties)) error

func (*GraphChanges) AddVerticesFrom

func (c *GraphChanges) AddVerticesFrom(g construct.Graph) error

func (*GraphChanges) AssertEqual

func (expected *GraphChanges) AssertEqual(t *testing.T, actual *GraphChanges)

func (*GraphChanges) RemoveEdge

func (c *GraphChanges) RemoveEdge(source, target construct.ResourceId) error

func (*GraphChanges) RemoveVertex

func (c *GraphChanges) RemoveVertex(hash construct.ResourceId) error

Jump to

Keyboard shortcuts

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