testutil

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 3, 2025 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssertMessagesEqual

func AssertMessagesEqual(t *testing.T, expected, actual *types.Message)

AssertMessagesEqual compares two messages for equality

func CreateTestError

func CreateTestError(t *testing.T, id types.ID, code int, message string) *types.Message

CreateTestError creates a Message containing an error

func CreateTestMessage

func CreateTestMessage(t *testing.T, id *types.ID, method string, params interface{}) *types.Message

CreateTestMessage creates a Message with the given fields

func CreateTestResult

func CreateTestResult(t *testing.T, id types.ID, result interface{}) *types.Message

CreateTestResult creates a Message containing a result

func ErrorsEqual

func ErrorsEqual(a, b *types.ErrorResponse) bool

ErrorsEqual compares two error responses for equality

func IDsEqual

func IDsEqual(a, b *types.ID) bool

IDsEqual compares two IDs for equality

func JSONDeepEqual

func JSONDeepEqual(a, b interface{}) bool

JSONDeepEqual compares two JSON values for deep equality

func JSONDeepEqualValue

func JSONDeepEqualValue(a, b interface{}) bool

JSONDeepEqualValue compares two JSON values for deep equality

func JSONEqual

func JSONEqual(t *testing.T, a, b *json.RawMessage) bool

JSONEqual compares two JSON messages for equality

func MarshalResult

func MarshalResult(v interface{}) (*json.RawMessage, error)

MarshalResult marshals the given result into a json.RawMessage

Types

type TestLogger

type TestLogger struct {
	// contains filtered or unexported fields
}

TestLogger provides a thread-safe logging buffer for tests

func NewTestLogger

func NewTestLogger(t *testing.T) *TestLogger

NewTestLogger creates a new TestLogger

func (*TestLogger) Logf

func (l *TestLogger) Logf(format string, args ...interface{})

Logf writes a formatted log message to the buffer

func (*TestLogger) String

func (l *TestLogger) String() string

String returns the current contents of the log buffer

Jump to

Keyboard shortcuts

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