testutil

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package testutil provides shared test utilities for the git-vendor project. These helpers are designed for testing serialization (YAML/JSON) round-trips and field validation across multiple packages.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertEqual

func AssertEqual[T any](t *testing.T, got, want T, msg string)

AssertEqual fails the test if got != want using reflect.DeepEqual.

func AssertError

func AssertError(t *testing.T, err error, msg string)

AssertError fails the test if err is nil.

func AssertJSONContainsField

func AssertJSONContainsField(t *testing.T, v any, fieldName string)

AssertJSONContainsField verifies a field is present in marshalled JSON output. Parses JSON into a map and recursively checks for key presence to avoid false positives from string values containing field-like patterns.

func AssertJSONOmitsField

func AssertJSONOmitsField(t *testing.T, v any, fieldName string)

AssertJSONOmitsField verifies a field is not present in marshalled JSON output. Parses JSON into a map and recursively checks for key presence to avoid false positives from string values containing field-like patterns.

func AssertJSONRoundTrip

func AssertJSONRoundTrip[T any](t *testing.T, original T)

AssertJSONRoundTrip marshals v to JSON and unmarshals back, failing if not equal. Uses reflect.DeepEqual for comparison.

func AssertNoError

func AssertNoError(t *testing.T, err error, msg string)

AssertNoError fails the test if err is not nil.

func AssertNotEqual

func AssertNotEqual[T any](t *testing.T, got, notWant T, msg string)

AssertNotEqual fails the test if got == want using reflect.DeepEqual.

func AssertYAMLContainsField

func AssertYAMLContainsField(t *testing.T, v any, fieldName string)

AssertYAMLContainsField verifies a field is present in marshalled YAML output. Parses YAML into a map and recursively checks for key presence to avoid false positives from string values containing field-like patterns.

func AssertYAMLOmitsField

func AssertYAMLOmitsField(t *testing.T, v any, fieldName string)

AssertYAMLOmitsField verifies a field is not present in marshalled YAML output. Parses YAML into a map and recursively checks for key presence to avoid false positives from string values containing field-like patterns.

func AssertYAMLRoundTrip

func AssertYAMLRoundTrip[T any](t *testing.T, original T)

AssertYAMLRoundTrip marshals v to YAML and unmarshals back, failing if not equal. Uses reflect.DeepEqual for comparison.

func BoolPtr

func BoolPtr(b bool) *bool

BoolPtr creates a pointer to a bool - useful for optional fields in tests.

func IntPtr

func IntPtr(i int) *int

IntPtr creates a pointer to an int - useful for optional fields in tests.

func StrPtr

func StrPtr(s string) *string

StrPtr creates a pointer to a string - useful for optional fields in tests.

Types

This section is empty.

Jump to

Keyboard shortcuts

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