testutil

package
v0.1.1-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2026 License: MIT Imports: 6 Imported by: 0

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

func ExtractAccessibleFields(t reflect.Type) map[string]bool

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

func ExtractJSONFields(t reflect.Type) map[string]bool

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.

Jump to

Keyboard shortcuts

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