testutils

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Dec 14, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package testutils provides shared utilities for JSON Patch testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyOperation

func ApplyOperation(t *testing.T, doc interface{}, operation jsonpatch.Operation) interface{}

ApplyOperation applies a single operation to a document

func ApplyOperationWithError

func ApplyOperationWithError(t *testing.T, doc interface{}, operation jsonpatch.Operation) error

ApplyOperationWithError applies an operation expecting it to fail

func ApplyOperations

func ApplyOperations(t *testing.T, doc interface{}, operations []jsonpatch.Operation) interface{}

ApplyOperations applies multiple operations to a document

func ApplyOperationsWithError

func ApplyOperationsWithError(t *testing.T, doc interface{}, operations []jsonpatch.Operation) error

ApplyOperationsWithError applies multiple operations expecting them to fail

func RunMultiOperationTestCase

func RunMultiOperationTestCase(t *testing.T, tc MultiOperationTestCase)

RunMultiOperationTestCase executes a multi-operation test case

func RunMultiOperationTestCases

func RunMultiOperationTestCases(t *testing.T, testCases []MultiOperationTestCase)

RunMultiOperationTestCases executes multiple multi-operation test cases

func RunTestCase

func RunTestCase(t *testing.T, tc TestCase)

RunTestCase executes a single test case

func RunTestCases

func RunTestCases(t *testing.T, testCases []TestCase)

RunTestCases executes multiple test cases

Types

type MultiOperationTestCase

type MultiOperationTestCase struct {
	Name       string                // Test case name
	Doc        interface{}           // Input document
	Operations []jsonpatch.Operation // Operations to apply
	Expected   interface{}           // Expected result
	ShouldFail bool                  // Whether operations should fail
	Comment    string                // Comment or source information
}

MultiOperationTestCase represents a multi-operation test case

type TestCase

type TestCase struct {
	Name       string              // Test case name
	Doc        interface{}         // Input document
	Operation  jsonpatch.Operation // Operation to apply
	Expected   interface{}         // Expected result
	ShouldFail bool                // Whether operation should fail
	Comment    string              // Comment or source information
}

TestCase represents a single operation test case

Jump to

Keyboard shortcuts

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