testutils

package
v0.7.9 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 5 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 ApplyInternalOp added in v0.5.9

func ApplyInternalOp(t *testing.T, doc any, op internal.Operation) any

ApplyInternalOp applies a single internal.Operation to a document.

func ApplyInternalOpWithError added in v0.5.9

func ApplyInternalOpWithError(t *testing.T, doc any, op internal.Operation)

ApplyInternalOpWithError applies an internal.Operation expecting it to fail.

func ApplyInternalOperationsResult added in v0.7.8

func ApplyInternalOperationsResult[T jsonpatch.Document](t testing.TB, doc T, ops []internal.Operation) (*jsonpatch.Result[T], error)

ApplyInternalOperationsResult compiles and applies internal.Operation test values.

func ApplyInternalOps added in v0.5.9

func ApplyInternalOps(t *testing.T, doc any, ops []internal.Operation) any

ApplyInternalOps applies multiple internal.Operations to a document.

func ApplyInternalOpsWithError added in v0.5.9

func ApplyInternalOpsWithError(t *testing.T, doc any, ops []internal.Operation)

ApplyInternalOpsWithError applies multiple internal.Operations expecting them to fail.

func ApplyOperation

func ApplyOperation(t *testing.T, doc any, operation jsoncodec.Operation) any

ApplyOperation applies a single operation to a document.

func ApplyOperationWithError

func ApplyOperationWithError(t *testing.T, doc any, operation jsoncodec.Operation) error

ApplyOperationWithError applies an operation expecting it to fail.

func ApplyOperations

func ApplyOperations(t *testing.T, doc any, operations []jsoncodec.Operation) any

ApplyOperations applies multiple operations to a document.

func ApplyOperationsResult added in v0.7.8

func ApplyOperationsResult[T jsonpatch.Document](t testing.TB, doc T, operations []jsoncodec.Operation) (*jsonpatch.Result[T], error)

ApplyOperationsResult compiles and applies JSON-shaped operations.

func ApplyOperationsWithError

func ApplyOperationsWithError(t *testing.T, doc any, operations []jsoncodec.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
	Doc        any
	Operations []jsoncodec.Operation
	Expected   any
	WantErr    bool
	Comment    string
}

MultiOperationTestCase represents a multi-operation test case.

type TestCase

type TestCase struct {
	Name      string
	Doc       any
	Operation jsoncodec.Operation
	Expected  any
	WantErr   bool
	Comment   string
}

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