mocks

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 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 BlamerMock added in v0.12.0

type BlamerMock struct {
	// FileBlameFunc mocks the FileBlame method.
	FileBlameFunc func(ref string, file string, staged bool) (map[int]diff.BlameLine, error)
	// contains filtered or unexported fields
}

BlamerMock is a mock implementation of ui.Blamer.

func TestSomethingThatUsesBlamer(t *testing.T) {

	// make and configure a mocked ui.Blamer
	mockedBlamer := &BlamerMock{
		FileBlameFunc: func(ref string, file string, staged bool) (map[int]diff.BlameLine, error) {
			panic("mock out the FileBlame method")
		},
	}

	// use mockedBlamer in code that requires ui.Blamer
	// and then make assertions.

}

func (*BlamerMock) FileBlame added in v0.12.0

func (mock *BlamerMock) FileBlame(ref string, file string, staged bool) (map[int]diff.BlameLine, error)

FileBlame calls FileBlameFunc.

func (*BlamerMock) FileBlameCalls added in v0.12.0

func (mock *BlamerMock) FileBlameCalls() []struct {
	Ref    string
	File   string
	Staged bool
}

FileBlameCalls gets all the calls that were made to FileBlame. Check the length with:

len(mockedBlamer.FileBlameCalls())

type RendererMock

type RendererMock struct {
	// ChangedFilesFunc mocks the ChangedFiles method.
	ChangedFilesFunc func(ref string, staged bool) ([]string, error)

	// FileDiffFunc mocks the FileDiff method.
	FileDiffFunc func(ref string, file string, staged bool) ([]diff.DiffLine, error)
	// contains filtered or unexported fields
}

RendererMock is a mock implementation of ui.Renderer.

func TestSomethingThatUsesRenderer(t *testing.T) {

	// make and configure a mocked ui.Renderer
	mockedRenderer := &RendererMock{
		ChangedFilesFunc: func(ref string, staged bool) ([]string, error) {
			panic("mock out the ChangedFiles method")
		},
		FileDiffFunc: func(ref string, file string, staged bool) ([]diff.DiffLine, error) {
			panic("mock out the FileDiff method")
		},
	}

	// use mockedRenderer in code that requires ui.Renderer
	// and then make assertions.

}

func (*RendererMock) ChangedFiles

func (mock *RendererMock) ChangedFiles(ref string, staged bool) ([]string, error)

ChangedFiles calls ChangedFilesFunc.

func (*RendererMock) ChangedFilesCalls

func (mock *RendererMock) ChangedFilesCalls() []struct {
	Ref    string
	Staged bool
}

ChangedFilesCalls gets all the calls that were made to ChangedFiles. Check the length with:

len(mockedRenderer.ChangedFilesCalls())

func (*RendererMock) FileDiff

func (mock *RendererMock) FileDiff(ref string, file string, staged bool) ([]diff.DiffLine, error)

FileDiff calls FileDiffFunc.

func (*RendererMock) FileDiffCalls

func (mock *RendererMock) FileDiffCalls() []struct {
	Ref    string
	File   string
	Staged bool
}

FileDiffCalls gets all the calls that were made to FileDiff. Check the length with:

len(mockedRenderer.FileDiffCalls())

type SyntaxHighlighterMock

type SyntaxHighlighterMock struct {
	// HighlightLinesFunc mocks the HighlightLines method.
	HighlightLinesFunc func(filename string, lines []diff.DiffLine) []string
	// contains filtered or unexported fields
}

SyntaxHighlighterMock is a mock implementation of ui.SyntaxHighlighter.

func TestSomethingThatUsesSyntaxHighlighter(t *testing.T) {

	// make and configure a mocked ui.SyntaxHighlighter
	mockedSyntaxHighlighter := &SyntaxHighlighterMock{
		HighlightLinesFunc: func(filename string, lines []diff.DiffLine) []string {
			panic("mock out the HighlightLines method")
		},
	}

	// use mockedSyntaxHighlighter in code that requires ui.SyntaxHighlighter
	// and then make assertions.

}

func (*SyntaxHighlighterMock) HighlightLines

func (mock *SyntaxHighlighterMock) HighlightLines(filename string, lines []diff.DiffLine) []string

HighlightLines calls HighlightLinesFunc.

func (*SyntaxHighlighterMock) HighlightLinesCalls

func (mock *SyntaxHighlighterMock) HighlightLinesCalls() []struct {
	Filename string
	Lines    []diff.DiffLine
}

HighlightLinesCalls gets all the calls that were made to HighlightLines. Check the length with:

len(mockedSyntaxHighlighter.HighlightLinesCalls())

Jump to

Keyboard shortcuts

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