mocks

package
v1.94.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CacheServiceMock

type CacheServiceMock struct {
	// PurgeFunc mocks the Purge method.
	PurgeFunc func(ctx context.Context, params cache.CachePurgeParams, opts ...option.RequestOption) (*cache.CachePurgeResponse, error)
	// contains filtered or unexported fields
}

CacheServiceMock is a mock implementation of cloudflare.CacheService.

func TestSomethingThatUsesCacheService(t *testing.T) {

	// make and configure a mocked cloudflare.CacheService
	mockedCacheService := &CacheServiceMock{
		PurgeFunc: func(ctx context.Context, params cache.CachePurgeParams, opts ...option.RequestOption) (*cache.CachePurgeResponse, error) {
			panic("mock out the Purge method")
		},
	}

	// use mockedCacheService in code that requires cloudflare.CacheService
	// and then make assertions.

}

func (*CacheServiceMock) Purge

Purge calls PurgeFunc.

func (*CacheServiceMock) PurgeCalls

func (mock *CacheServiceMock) PurgeCalls() []struct {
	Ctx    context.Context
	Params cache.CachePurgeParams
	Opts   []option.RequestOption
}

PurgeCalls gets all the calls that were made to Purge. Check the length with:

len(mockedCacheService.PurgeCalls())

type ClienterMock

type ClienterMock struct {
	// PurgeByPrefixesFunc mocks the PurgeByPrefixes method.
	PurgeByPrefixesFunc func(ctx context.Context, prefixes []string) error
	// contains filtered or unexported fields
}

ClienterMock is a mock implementation of cloudflare.Clienter.

func TestSomethingThatUsesClienter(t *testing.T) {

	// make and configure a mocked cloudflare.Clienter
	mockedClienter := &ClienterMock{
		PurgeByPrefixesFunc: func(ctx context.Context, prefixes []string) error {
			panic("mock out the PurgeByPrefixes method")
		},
	}

	// use mockedClienter in code that requires cloudflare.Clienter
	// and then make assertions.

}

func (*ClienterMock) PurgeByPrefixes

func (mock *ClienterMock) PurgeByPrefixes(ctx context.Context, prefixes []string) error

PurgeByPrefixes calls PurgeByPrefixesFunc.

func (*ClienterMock) PurgeByPrefixesCalls

func (mock *ClienterMock) PurgeByPrefixesCalls() []struct {
	Ctx      context.Context
	Prefixes []string
}

PurgeByPrefixesCalls gets all the calls that were made to PurgeByPrefixes. Check the length with:

len(mockedClienter.PurgeByPrefixesCalls())

Jump to

Keyboard shortcuts

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