conformance

package
v1.18.14 Latest Latest
Warning

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

Go to latest
Published: May 3, 2026 License: BSD-3-Clause Imports: 4 Imported by: 0

Documentation

Overview

Package conformance provides structural comparison of JSON API responses for validating PeeringDB compatibility layer output against the real PeeringDB API. Comparison is structure-only: field names, value types, and nesting depth are checked, but actual values are not.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ExtractStructure

func ExtractStructure(jsonBody []byte) (map[string]any, error)

ExtractStructure parses a JSON body and returns it as a map for structural comparison. The input should be a PeeringDB JSON envelope ({"meta":{},"data":[...]}).

Types

type Difference

type Difference struct {
	Path    string // JSON path, e.g., "data[0].net_set[0].asn"
	Kind    string // "missing_field", "extra_field", "type_mismatch"
	Details string // Human-readable description
}

Difference describes a structural mismatch between two JSON responses.

func CompareResponses

func CompareResponses(reference, actual []byte) ([]Difference, error)

CompareResponses is a convenience wrapper that extracts structure from both JSON bodies and compares them. It returns differences found between the reference and actual response structures.

func CompareStructure

func CompareStructure(reference, actual map[string]any) []Difference

CompareStructure compares the JSON structure of reference and actual maps. It checks field names, value types (string, number, bool, null, array, object), and nesting depth. Values are not compared. Differences are returned sorted by Path for deterministic output.

Jump to

Keyboard shortcuts

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