mocks

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientMock

type ClientMock struct {
	// PullFunc mocks the Pull method.
	PullFunc func(ctx context.Context, reference string, opts *oras.AuthOptions) (*oras.PullDescriptor, error)

	// PushFunc mocks the Push method.
	PushFunc func(ctx context.Context, reference string, descriptor *oras.PushDescriptor, opts *oras.AuthOptions) error
	// contains filtered or unexported fields
}

ClientMock is a mock implementation of oras.Client.

func TestSomethingThatUsesClient(t *testing.T) {

	// make and configure a mocked oras.Client
	mockedClient := &ClientMock{
		PullFunc: func(ctx context.Context, reference string, opts *oras.AuthOptions) (*oras.PullDescriptor, error) {
			panic("mock out the Pull method")
		},
		PushFunc: func(ctx context.Context, reference string, descriptor *oras.PushDescriptor, opts *oras.AuthOptions) error {
			panic("mock out the Push method")
		},
	}

	// use mockedClient in code that requires oras.Client
	// and then make assertions.

}

func (*ClientMock) Pull

func (mock *ClientMock) Pull(ctx context.Context, reference string, opts *oras.AuthOptions) (*oras.PullDescriptor, error)

Pull calls PullFunc.

func (*ClientMock) PullCalls

func (mock *ClientMock) PullCalls() []struct {
	Ctx       context.Context
	Reference string
	Opts      *oras.AuthOptions
}

PullCalls gets all the calls that were made to Pull. Check the length with:

len(mockedClient.PullCalls())

func (*ClientMock) Push

func (mock *ClientMock) Push(ctx context.Context, reference string, descriptor *oras.PushDescriptor, opts *oras.AuthOptions) error

Push calls PushFunc.

func (*ClientMock) PushCalls

func (mock *ClientMock) PushCalls() []struct {
	Ctx        context.Context
	Reference  string
	Descriptor *oras.PushDescriptor
	Opts       *oras.AuthOptions
}

PushCalls gets all the calls that were made to Push. Check the length with:

len(mockedClient.PushCalls())

Jump to

Keyboard shortcuts

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