verify

package
v3.16.0 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CompareJSON

func CompareJSON(expected, actual interface{}) error

CompareJSON does a deep subset comparison of two JSON-decoded values: every key present in expected must exist in actual with a matching value. Extra keys in actual are ignored. Array elements are compared positionally and must match exactly (same length, same element values).

func ExtractVerifyRulesForTarget

func ExtractVerifyRulesForTarget(rules []types.VerifyRule, targetType string) []types.VerifyRule

ExtractVerifyRulesForTarget filters verification rules for a specific target type This helps proxies only process rules relevant to their protocol

func MakeJSONBodyMatcher

func MakeJSONBodyMatcher(actualBody, sourceLabel string, resolver *interpolate.Resolver) func(withFile, baseDir string) bool

MakeJSONBodyMatcher returns a registry body-match callback shared by the HTTP and Kafka interceptors. When the mock has no WithFile the callback always returns true (match-any). Otherwise it loads the expected payload from withFile, parses actualBody as JSON, and delegates to CompareJSON. sourceLabel names the body source in the parse-failure debug log (e.g. "request body" or "Kafka message value").

func VerifyGRPC

func VerifyGRPC(req *GRPCRequest, rules []types.VerifyRule) error

VerifyGRPC checks a gRPC request against a set of verification rules

func VerifyHTTP

func VerifyHTTP(req *HTTPRequest, rules []types.VerifyRule) error

VerifyHTTP checks an HTTP request against a set of verification rules

func VerifyKafka

func VerifyKafka(msg *KafkaMessage, rules []types.VerifyRule) error

VerifyKafka checks a Kafka message against a set of verification rules

func VerifyRedis

func VerifyRedis(cmd *RedisCommand, rules []types.VerifyRule) error

VerifyRedis checks a Redis command against a set of verification rules

func VerifySQL

func VerifySQL(query string, rules []types.VerifyRule) error

VerifySQL checks a SQL query against a set of verification rules

func VerifyTarget

func VerifyTarget(targetName string, actual string, rules []types.VerifyRule) error

VerifyTarget checks a target value against a set of verification rules

Types

type GRPCRequest

type GRPCRequest struct {
	Service  string
	Method   string
	Body     string            // JSON representation of the request message
	Metadata map[string]string // gRPC metadata (like HTTP headers)
}

GRPCRequest holds gRPC request data for verification

type HTTPRequest

type HTTPRequest struct {
	Method  string
	URL     string
	Path    string
	Headers map[string]string
	Body    string
}

HTTPRequest holds HTTP request data for verification

type KafkaMessage

type KafkaMessage struct {
	Key     string
	Value   string
	Headers map[string]string
}

KafkaMessage holds Kafka message data for verification

type RedisCommand

type RedisCommand struct {
	Command string
	Key     string
	Value   string
	Args    []string
}

RedisCommand holds Redis command data for verification

type VerificationError

type VerificationError struct {
	Target  string
	Rule    types.VerifyRule
	Actual  string
	Message string
}

VerificationError represents a failed verification

func (*VerificationError) Error

func (e *VerificationError) Error() string

Jump to

Keyboard shortcuts

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