Documentation
¶
Index ¶
- Variables
- func AssertAdvertisedCapabilityHasBuilder(t *testing.T, capability string, advertised bool, builder func() any)
- func AssertBuilderMatchesCapability(t *testing.T, capability string, advertised bool, builder func() any)
- func CompareResults(t *testing.T, actualString []byte, referenceString []byte) error
- func EnrichOptionsWithOptionsForTesting(t *testing.T, _options ...options.WithOption) []options.WithOption
- func ExplodingGlobalLogger(hardExplode bool)
- func ParseDriverTestsuiteXml(t *testing.T, testPath string) *xmldom.Node
- func ParseParserSerializerTestSuiteXml(t *testing.T, testPath string) *xmldom.Node
- func ProduceTestingLogger(t TestingLog) zerolog.Logger
- func RunDriverTestsuite(t *testing.T, driver plc4go.PlcDriver, testPath string, parser XmlParser, ...)
- func RunParserSerializerTestsuite(t *testing.T, testPath string, parser Parser, options ...options.WithOption)
- func RunParserTruncationTestsuite(t *testing.T, testPath string, parser Parser, options ...options.WithOption)
- func TestContext(t *testing.T) context.Context
- func WithRootTypeParser(rootTypeParser func(utils.ReadBufferByteBased) (any, error)) config.WithOption
- func WithSkippedTestCases(skippedTestCases ...string) config.WithOption
- type ConnectionConnectAwaiter
- type DriverTestStep
- type DriverTestcase
- type DriverTestsuite
- func (m DriverTestsuite) ExecuteStep(t *testing.T, connection plc4go.PlcConnection, testcase *DriverTestcase, ...) error
- func (DriverTestsuite) LogDelimiterSection(t *testing.T, delimiter, format string, a ...any)
- func (m DriverTestsuite) Run(t *testing.T, driverManager plc4go.PlcDriverManager, testcase DriverTestcase) error
- type ManualTestCase
- type ManualTestSuite
- type Parser
- type ParserSerializerTestcase
- type ParserSerializerTestsuite
- type StepType
- type TestTransportInstance
- type TestingLog
- type WithTestCaseOption
- type XmlParser
Constants ¶
This section is empty.
Variables ¶
var DriverTestsuiteConnectTimeout = 30 * time.Second
Functions ¶
func AssertAdvertisedCapabilityHasBuilder ¶
func AssertAdvertisedCapabilityHasBuilder(t *testing.T, capability string, advertised bool, builder func() any)
AssertAdvertisedCapabilityHasBuilder checks the direction that always holds: a connection that advertises a capability has to hand out a builder for it. The converse is not asserted, because a driver may hand out a builder whose operations report "not implemented" while honestly advertising the capability as absent. Use AssertBuilderMatchesCapability for connections where both directions are supposed to hold.
func AssertBuilderMatchesCapability ¶
func AssertBuilderMatchesCapability(t *testing.T, capability string, advertised bool, builder func() any)
AssertBuilderMatchesCapability checks that a connection hands out a request builder exactly when its metadata advertises the matching capability. An advertised capability has to produce a builder, and an unadvertised one has to refuse rather than hand out a builder that cannot work.
func CompareResults ¶
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 ProduceTestingLogger ¶
func ProduceTestingLogger(t TestingLog) zerolog.Logger
ProduceTestingLogger produces a logger which redirects to testing.T
func RunDriverTestsuite ¶
func RunParserTruncationTestsuite ¶
func RunParserTruncationTestsuite(t *testing.T, testPath string, parser Parser, options ...options.WithOption)
RunParserTruncationTestsuite parses every prefix of every message in a parser-serializer testsuite and requires each one to fail, if it fails, as an error rather than as a panic.
The remote end decides where a message ends: a datagram can arrive short, and a stream can be closed mid-message, so every prefix of a well formed message is something a driver can be handed. Truncation is worth exercising in particular because a field read that runs out of bytes is reported as an absent optional rather than as a failure, so anything deriving a value from that field sees it unset in a case the surrounding condition says cannot happen.
The reference messages of a testsuite make a far better corpus for this than hand-written input, because they reach every type the protocol's own tests reach. Whether a prefix parses is left open - a truncated message may legitimately parse into a smaller one. Only the manner of failure is asserted.
func TestContext ¶
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
}
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 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 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 ¶
func (p *ParserSerializerTestsuite) Run(t *testing.T, testcase ParserSerializerTestcase) error
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 )
type TestTransportInstance ¶
type TestTransportInstance interface {
transports.TransportInstance
FillReadBuffer(data []byte)
GetNumDrainableBytes() uint32
DrainWriteBuffer(numBytes uint32) []byte
}
type TestingLog ¶
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