packet_test

package
v0.0.0-...-9f5628c Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2023 License: LGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package packet_test contains some utility functions for creating feature tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FeatureLine

type FeatureLine struct {
	// When is the point in time this was exported
	When flows.DateTimeNanoseconds
	// Features is a list of feature results
	Features []FeatureResult
}

FeatureLine holds one record (i.e. Feature results + point in time)

type FeatureResult

type FeatureResult struct {
	// Name of the feature
	Name string
	// Value of the feature
	Value interface{}
}

FeatureResult holds the result for the named feature

type TestTable

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

TestTable is flow table implementation which can be used for testing

func MakeFeatureTest

func MakeFeatureTest(t *testing.T, features []string, ft flows.FeatureType, opt flows.FlowOptions) (ret TestTable)

MakeFeatureTest creates a flow table for testing purposes with the given features, wanted return type, and flow options

func MakeFlowFeatureTest

func MakeFlowFeatureTest(t *testing.T, feature string) TestTable

MakeFlowFeatureTest returns a flow table for testing a single flow feature

func MakePacketFeatureTest

func MakePacketFeatureTest(t *testing.T, feature string) TestTable

MakePacketFeatureTest returns a flow table for testing a single packet feature

func (*TestTable) AssertFeatureList

func (t *TestTable) AssertFeatureList(result []FeatureLine)

AssertFeatureList fails the test if the table did not export the given resultset

func (*TestTable) AssertFeatureValue

func (t *TestTable) AssertFeatureValue(name string, value interface{})

AssertFeatureValue fails the test if the named feature did not return the expected value

func (*TestTable) EventLayers

func (t *TestTable) EventLayers(when flows.DateTimeNanoseconds, layerList ...packet.SerializableLayerType)

EventLayers simulates a packet arriving at the given point in time with the given layers populated

func (*TestTable) Finish

func (t *TestTable) Finish(when flows.DateTimeNanoseconds)

Finish finalizes all the flows in the table

Jump to

Keyboard shortcuts

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