graphtest

package
v0.0.0-...-e098d20 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package graphtest provides test utilities for asserting properties of event graphs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertGraph

func AssertGraph(t *testing.T, bufs [][]byte, numNodes int, asserterMap AsserterMap)

AssertGraph builds a graph from encoded events and asserts properties and edges about each node in asserterMap.

Types

type AssertNodeKVMap

type AssertNodeKVMap map[MatchNodeKV]NodeAsserter

An AssertNodeKVMap describes a list of nodes by {Layer, Label, K, V} and assertions about them.

func (AssertNodeKVMap) AssertMissing

func (m AssertNodeKVMap) AssertMissing(t *testing.T)

AssertMissing ensures each node is seen.

func (AssertNodeKVMap) AssertSeen

func (m AssertNodeKVMap) AssertSeen(t *testing.T, n Node)

AssertSeen ensures each node is seen at most once.

func (AssertNodeKVMap) Match

func (m AssertNodeKVMap) Match(n Node) (ret NodeAsserter, ok bool)

Match a node by KV pair, returning an asserter.

func (AssertNodeKVMap) Size

func (m AssertNodeKVMap) Size() (ret int)

Size returns the number of nodes in the asserted graph.

type AssertNodeMap

type AssertNodeMap map[MatchNode]NodeAsserter

An AssertNodeMap describes a list of nodes by {Layer, Label} and assertions about them.

func (AssertNodeMap) AssertMissing

func (m AssertNodeMap) AssertMissing(t *testing.T)

AssertMissing ensures each node is seen.

func (AssertNodeMap) AssertSeen

func (m AssertNodeMap) AssertSeen(t *testing.T, n Node)

AssertSeen ensures each node is seen at most once.

func (AssertNodeMap) Match

func (m AssertNodeMap) Match(n Node) (NodeAsserter, bool)

Match a node, returning an asserter.

func (AssertNodeMap) Size

func (m AssertNodeMap) Size() (ret int)

Size returns the number of nodes in the asserted graph.

type AsserterMap

type AsserterMap interface {
	Match(n Node) (NodeAsserter, bool)
	Size() int
	AssertSeen(t *testing.T, n Node)
	AssertMissing(t *testing.T)
}

An AsserterMap looks up NodeAsserters for Nodes in a graph, keeping track of which have been seen.

type Edges

type Edges []MatchNode

Edges is a list of outedges to assert on.

type MatchNode

type MatchNode struct{ Layer, Label string }

MatchNode describes a node by its Layer and Label, used to match for assertions about a node and when listing its outedges.

type MatchNodeKV

type MatchNodeKV struct{ Layer, Label, K, V string }

MatchNodeKV allows a test to assert properties of a node by specifying its Layer, Label and a KV pair.

type Node

type Node struct {
	Layer, Label string
	OpID         string
	Edges        []string
	Map          map[string]interface{}
	Flag         uint8
}

Node is a decoded event report used for testing assertions.

type NodeAsserter

type NodeAsserter struct {
	Edges    Edges
	Callback func(n Node)
	Count    int
	Seen     bool
}

NodeAsserter checks a list of outedges and calls cb to run more asserts for this node.

Jump to

Keyboard shortcuts

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