Documentation
¶
Overview ¶
Package testutil provides shared testing utilities for models packages.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExtractAccessibleFields ¶
ExtractAccessibleFields uses reflection to get all JSON field names from a struct, checking both exported struct fields (via JSON tags) and getter methods (for private fields).
func ExtractJSONFields ¶
ExtractJSONFields is the legacy compatibility wrapper. Use ExtractAccessibleFields for comprehensive checking that includes getter methods.
func RunSchemaConformance ¶
func RunSchemaConformance(t *testing.T, cfg SchemaConformanceConfig)
RunSchemaConformance validates that Go struct fields match JSON schema properties. Schema-driven: iterates through schema definitions and validates each against Go types. Supports both exported struct fields (with JSON tags) and unexported fields (with getter methods).
Types ¶
type SchemaConformanceConfig ¶
type SchemaConformanceConfig struct {
// SchemaPath is the path to the JSON schema file
SchemaPath string
// Types is the list of Go type instances to validate
Types []interface{}
// NameMappings maps schema definition names to Go type names where they differ
NameMappings map[string]string
// PropertyExclusions lists properties to skip per definition (e.g. schema bugs)
PropertyExclusions map[string][]string
}
SchemaConformanceConfig configures the schema conformance test.