mockpanicking

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: AGPL-3.0 Imports: 2 Imported by: 0

Documentation

Overview

Package mockpanicking provides mock implementations of the panicking package's interfaces. Both the hand-written testify-based Panicker and the moq-generated PanickerMock live here during the testify → moq migration. New test code should prefer PanickerMock.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type PanickerMock

type PanickerMock struct {
	// PanicFunc mocks the Panic method.
	PanicFunc func(v any)

	// PanicfFunc mocks the Panicf method.
	PanicfFunc func(format string, args ...any)
	// contains filtered or unexported fields
}

PanickerMock is a mock implementation of panicking.Panicker.

func TestSomethingThatUsesPanicker(t *testing.T) {

	// make and configure a mocked panicking.Panicker
	mockedPanicker := &PanickerMock{
		PanicFunc: func(v any)  {
			panic("mock out the Panic method")
		},
		PanicfFunc: func(format string, args ...any)  {
			panic("mock out the Panicf method")
		},
	}

	// use mockedPanicker in code that requires panicking.Panicker
	// and then make assertions.

}

func (*PanickerMock) Panic

func (mock *PanickerMock) Panic(v any)

Panic calls PanicFunc.

func (*PanickerMock) PanicCalls

func (mock *PanickerMock) PanicCalls() []struct {
	V any
}

PanicCalls gets all the calls that were made to Panic. Check the length with:

len(mockedPanicker.PanicCalls())

func (*PanickerMock) Panicf

func (mock *PanickerMock) Panicf(format string, args ...any)

Panicf calls PanicfFunc.

func (*PanickerMock) PanicfCalls

func (mock *PanickerMock) PanicfCalls() []struct {
	Format string
	Args   []any
}

PanicfCalls gets all the calls that were made to Panicf. Check the length with:

len(mockedPanicker.PanicfCalls())

Jump to

Keyboard shortcuts

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