mocks

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type StorerMock

type StorerMock struct {
	// CommitFunc mocks the Commit method.
	CommitFunc func(req git.CommitRequest) error

	// DeleteFunc mocks the Delete method.
	DeleteFunc func(key string, author git.Author) error

	// GetRevisionFunc mocks the GetRevision method.
	GetRevisionFunc func(key string, rev string) ([]byte, string, error)

	// HistoryFunc mocks the History method.
	HistoryFunc func(key string, limit int) ([]git.HistoryEntry, error)

	// PullFunc mocks the Pull method.
	PullFunc func() error

	// PushFunc mocks the Push method.
	PushFunc func() error
	// contains filtered or unexported fields
}

StorerMock is a mock implementation of git.Storer.

func TestSomethingThatUsesStorer(t *testing.T) {

	// make and configure a mocked git.Storer
	mockedStorer := &StorerMock{
		CommitFunc: func(req git.CommitRequest) error {
			panic("mock out the Commit method")
		},
		DeleteFunc: func(key string, author git.Author) error {
			panic("mock out the Delete method")
		},
		GetRevisionFunc: func(key string, rev string) ([]byte, string, error) {
			panic("mock out the GetRevision method")
		},
		HistoryFunc: func(key string, limit int) ([]git.HistoryEntry, error) {
			panic("mock out the History method")
		},
		PullFunc: func() error {
			panic("mock out the Pull method")
		},
		PushFunc: func() error {
			panic("mock out the Push method")
		},
	}

	// use mockedStorer in code that requires git.Storer
	// and then make assertions.

}

func (*StorerMock) Commit

func (mock *StorerMock) Commit(req git.CommitRequest) error

Commit calls CommitFunc.

func (*StorerMock) CommitCalls

func (mock *StorerMock) CommitCalls() []struct {
	Req git.CommitRequest
}

CommitCalls gets all the calls that were made to Commit. Check the length with:

len(mockedStorer.CommitCalls())

func (*StorerMock) Delete

func (mock *StorerMock) Delete(key string, author git.Author) error

Delete calls DeleteFunc.

func (*StorerMock) DeleteCalls

func (mock *StorerMock) DeleteCalls() []struct {
	Key    string
	Author git.Author
}

DeleteCalls gets all the calls that were made to Delete. Check the length with:

len(mockedStorer.DeleteCalls())

func (*StorerMock) GetRevision added in v0.12.0

func (mock *StorerMock) GetRevision(key string, rev string) ([]byte, string, error)

GetRevision calls GetRevisionFunc.

func (*StorerMock) GetRevisionCalls added in v0.12.0

func (mock *StorerMock) GetRevisionCalls() []struct {
	Key string
	Rev string
}

GetRevisionCalls gets all the calls that were made to GetRevision. Check the length with:

len(mockedStorer.GetRevisionCalls())

func (*StorerMock) History added in v0.12.0

func (mock *StorerMock) History(key string, limit int) ([]git.HistoryEntry, error)

History calls HistoryFunc.

func (*StorerMock) HistoryCalls added in v0.12.0

func (mock *StorerMock) HistoryCalls() []struct {
	Key   string
	Limit int
}

HistoryCalls gets all the calls that were made to History. Check the length with:

len(mockedStorer.HistoryCalls())

func (*StorerMock) Pull

func (mock *StorerMock) Pull() error

Pull calls PullFunc.

func (*StorerMock) PullCalls

func (mock *StorerMock) PullCalls() []struct {
}

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

len(mockedStorer.PullCalls())

func (*StorerMock) Push

func (mock *StorerMock) Push() error

Push calls PushFunc.

func (*StorerMock) PushCalls

func (mock *StorerMock) PushCalls() []struct {
}

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

len(mockedStorer.PushCalls())

Jump to

Keyboard shortcuts

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