Documentation
¶
Overview ¶
Package conformance provides shared helpers for porting message-level OCPP conformance tests.
Index ¶
- func MustValidator(t *testing.T, reg *schema.Registry, version, action, kind string) *schema.Validator
- func RoundTripCP[Req, Resp any](t *testing.T, subprotocol string, reg *schema.Registry, ...) (Resp, error)
- func RoundTripCSMS[Req, Resp any](t *testing.T, subprotocol string, reg *schema.Registry, ...) (Resp, error)
- func RunValidationTable(t *testing.T, v *schema.Validator, cases []ValidationCase)
- func SchemaRegistry(register func(*schema.Registry) error) *schema.Registry
- type ValidationCase
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustValidator ¶
func MustValidator(t *testing.T, reg *schema.Registry, version, action, kind string) *schema.Validator
MustValidator returns the registered validator or fails the test immediately.
func RoundTripCP ¶
func RoundTripCP[Req, Resp any]( t *testing.T, subprotocol string, reg *schema.Registry, register func(*cp.Client), msg ocppj.Message[Req, Resp], req Req, ) (Resp, error)
RoundTripCP starts a CSMS, connects a CP (which registers handlers via register), waits for the connection to appear, then sends one CSMS-originated request to the charge point and returns the typed response. Use this for SentByCSMS messages (the mirror of RoundTripCSMS).
func RoundTripCSMS ¶
func RoundTripCSMS[Req, Resp any]( t *testing.T, subprotocol string, reg *schema.Registry, register func(*csms.Server), msg ocppj.Message[Req, Resp], req Req, ) (Resp, error)
RoundTripCSMS starts a CSMS, connects a CP, sends one CP-originated request, and returns the typed response.
func RunValidationTable ¶
func RunValidationTable(t *testing.T, v *schema.Validator, cases []ValidationCase)
RunValidationTable marshals and validates each case as a named subtest.
func SchemaRegistry ¶ added in v0.1.6
SchemaRegistry returns a process-cached registry built by register (e.g. v21.RegisterSchemas). Building a registry eagerly compiles every schema for a version — ~24ms for 2.1's 181 schemas, far more under -race — so rebuilding it in each conformance test (which needs only a validator or two) dominated the suite's runtime. Caching one registry per register func makes every test after the first reuse it. The registry is read-only after building (validators are immutable and Lookup is read-locked), so sharing across tests is safe.
Types ¶
type ValidationCase ¶
ValidationCase is one named JSON Schema validation scenario.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package conf16a contains OCPP 1.6 per-message conformance tests.
|
Package conf16a contains OCPP 1.6 per-message conformance tests. |
|
Package conf16b contains OCPP 1.6 Group B conformance tests.
|
Package conf16b contains OCPP 1.6 Group B conformance tests. |
|
Package conf16c contains OCPP 1.6 per-message conformance tests for group C.
|
Package conf16c contains OCPP 1.6 per-message conformance tests for group C. |
|
Package conf201a contains OCPP 2.0.1 per-message conformance tests.
|
Package conf201a contains OCPP 2.0.1 per-message conformance tests. |
|
Package conf201b contains OCPP 2.0.1 per-message conformance tests.
|
Package conf201b contains OCPP 2.0.1 per-message conformance tests. |
|
Package conf201c contains OCPP 2.0.1 message-level conformance tests.
|
Package conf201c contains OCPP 2.0.1 message-level conformance tests. |
|
Package conf201d contains OCPP 2.0.1 per-message conformance tests for group 201-D.
|
Package conf201d contains OCPP 2.0.1 per-message conformance tests for group 201-D. |
|
Package conf201e contains OCPP 2.0.1 group 201-E message-level conformance tests.
|
Package conf201e contains OCPP 2.0.1 group 201-E message-level conformance tests. |
|
Package conf201f contains OCPP 2.0.1 per-message conformance tests for group 201-F.
|
Package conf201f contains OCPP 2.0.1 per-message conformance tests for group 201-F. |
|
Package conf21a contains GROUP 21-A per-message conformance tests for OCPP 2.1.
|
Package conf21a contains GROUP 21-A per-message conformance tests for OCPP 2.1. |
|
Package conf21b contains OCPP 2.1 GROUP 21-B per-message conformance tests.
|
Package conf21b contains OCPP 2.1 GROUP 21-B per-message conformance tests. |
|
Package conf21c contains OCPP 2.1 per-message conformance tests for group 21-C.
|
Package conf21c contains OCPP 2.1 per-message conformance tests for group 21-C. |
|
Package conf21d contains OCPP 2.1 group D conformance tests.
|
Package conf21d contains OCPP 2.1 group D conformance tests. |
|
Package conf21e contains OCPP 2.1 GROUP 21-E per-message conformance tests.
|
Package conf21e contains OCPP 2.1 GROUP 21-E per-message conformance tests. |
|
Package conf21f contains OCPP 2.1 per-message conformance tests (GROUP 21-F).
|
Package conf21f contains OCPP 2.1 per-message conformance tests (GROUP 21-F). |
|
Package conf21g contains OCPP 2.1 group G per-message conformance tests.
|
Package conf21g contains OCPP 2.1 group G per-message conformance tests. |