testutils

package
v0.0.0-...-f9e1acc Latest Latest
Warning

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

Go to latest
Published: Apr 30, 2024 License: Apache-2.0 Imports: 35 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DriverTestsuiteConnectTimeout = 30 * time.Second

Functions

func CompareResults

func CompareResults(t *testing.T, actualString []byte, referenceString []byte) error

func EnrichOptionsWithOptionsForTesting

func EnrichOptionsWithOptionsForTesting(t *testing.T, _options ...options.WithOption) []options.WithOption

EnrichOptionsWithOptionsForTesting appends options useful for testing to config.WithOption s

func ExplodingGlobalLogger

func ExplodingGlobalLogger(hardExplode bool)

ExplodingGlobalLogger Useful to find unredirected logs

func ParseDriverTestsuiteXml

func ParseDriverTestsuiteXml(t *testing.T, testPath string) *xmldom.Node

func ParseParserSerializerTestSuiteXml

func ParseParserSerializerTestSuiteXml(t *testing.T, testPath string) *xmldom.Node

func ProduceTestingLogger

func ProduceTestingLogger(t TestingLog) zerolog.Logger

ProduceTestingLogger produces a logger which redirects to testing.T

func RunDriverTestsuite

func RunDriverTestsuite(t *testing.T, driver plc4go.PlcDriver, testPath string, parser XmlParser, _options ...options.WithOption)

func RunParserSerializerTestsuite

func RunParserSerializerTestsuite(t *testing.T, testPath string, parser Parser, options ...options.WithOption)

func TestContext

func TestContext(t *testing.T) context.Context

TestContext produces a context which is getting cleaned up by testing.T

func WithRootTypeParser

func WithRootTypeParser(rootTypeParser func(utils.ReadBufferByteBased) (any, error)) config.WithOption

WithRootTypeParser can be used to output the root type of protocol for better debugging

func WithSkippedTestCases

func WithSkippedTestCases(skippedTestCases ...string) config.WithOption

WithSkippedTestCases can be used to skip test cases

Types

type ConnectionConnectAwaiter

type ConnectionConnectAwaiter interface {
	// SetAwaitSetupComplete sets a flag that the driver should await a connection completion
	SetAwaitSetupComplete(awaitComplete bool)
	// SetAwaitDisconnectComplete sets a flag that the driver should await a dis-connection completion
	SetAwaitDisconnectComplete(awaitComplete bool)
}

type DriverTestStep

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

func ParseDriverTestsuiteSteps

func ParseDriverTestsuiteSteps(t *testing.T, node xmldom.Node) ([]DriverTestStep, error)

type DriverTestcase

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

type DriverTestsuite

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

func ParseDriverTestsuite

func ParseDriverTestsuite(t *testing.T, node xmldom.Node, parser XmlParser, rootTypeParser func(utils.ReadBufferByteBased) (any, error)) *DriverTestsuite

func (DriverTestsuite) ExecuteStep

func (m DriverTestsuite) ExecuteStep(t *testing.T, connection plc4go.PlcConnection, testcase *DriverTestcase, step DriverTestStep) error

func (DriverTestsuite) LogDelimiterSection

func (DriverTestsuite) LogDelimiterSection(t *testing.T, delimiter, format string, a ...any)

func (DriverTestsuite) Run

func (m DriverTestsuite) Run(t *testing.T, driverManager plc4go.PlcDriverManager, testcase DriverTestcase) error

type ManualTestCase

type ManualTestCase struct {
	Address           string
	ExpectedReadValue any
	WriteValue        any
	UnwrappedValue    bool
}

type ManualTestSuite

type ManualTestSuite struct {
	ConnectionString string
	DriverManager    plc4go.PlcDriverManager
	TestCases        []ManualTestCase
	// contains filtered or unexported fields
}

func NewManualTestSuite

func NewManualTestSuite(t *testing.T, connectionString string, driverManager plc4go.PlcDriverManager) *ManualTestSuite

func (*ManualTestSuite) AddTestCase

func (m *ManualTestSuite) AddTestCase(address string, expectedReadValue any, testCaseOptions ...WithTestCaseOption)

func (*ManualTestSuite) Run

func (m *ManualTestSuite) Run() plc4go.PlcConnection

type Parser

type Parser interface {
	Parse(typeName string, arguments []string, io utils.ReadBuffer) (any, error)
}

type ParserSerializerTestcase

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

type ParserSerializerTestsuite

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

func ParseParserSerializerTestSuite

func ParseParserSerializerTestSuite(t *testing.T, node xmldom.Node, parser Parser, rootTypeParser func(utils.ReadBufferByteBased) (any, error)) *ParserSerializerTestsuite

func (*ParserSerializerTestsuite) Run

type StepType

type StepType uint8
const (
	StepTypeOutgoingPlcMessage StepType = 0x01
	StepTypeOutgoingPlcBytes   StepType = 0x02
	StepTypeIncomingPlcMessage StepType = 0x03
	StepTypeIncomingPlcBytes   StepType = 0x04
	StepTypeApiRequest         StepType = 0x05
	StepTypeApiResponse        StepType = 0x06
	StepTypeDelay              StepType = 0x07
	StepTypeTerminate          StepType = 0x08
)

func (StepType) String

func (i StepType) String() string

type TestTransportInstance

type TestTransportInstance interface {
	transports.TransportInstance
	FillReadBuffer(data []byte)
	GetNumDrainableBytes() uint32
	DrainWriteBuffer(numBytes uint32) []byte
}

type TestingLog

type TestingLog interface {
	Log(args ...interface{})
	Logf(format string, args ...interface{})
	Helper()
}

type WithTestCaseOption

type WithTestCaseOption func(testCase ManualTestCase)

func WithUnwrappedValue

func WithUnwrappedValue(unwrap bool) WithTestCaseOption

WithUnwrappedValue is a WithTestCaseOption which can be used to control if plc4go.PlcValue

type XmlParser

type XmlParser interface {
	Parse(typeName string, xmlString string, parserArguments ...string) (any, error)
}

Jump to

Keyboard shortcuts

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