Documentation
¶
Index ¶
- func Exec(args ...string) (bytes.Buffer, bytes.Buffer, error)
- func HasCommits() bool
- func HasRemote(name string) bool
- func IsDirty() bool
- func IsInitialized() bool
- func IsInstalled() bool
- func StatusLines() ([]string, error)
- type Client
- type ClientMock
- func (mock *ClientMock) Exec(args ...string) (bytes.Buffer, bytes.Buffer, error)
- func (mock *ClientMock) ExecCalls() []struct{ ... }
- func (mock *ClientMock) HasCommits() bool
- func (mock *ClientMock) HasCommitsCalls() []struct{}
- func (mock *ClientMock) HasRemote(name string) bool
- func (mock *ClientMock) HasRemoteCalls() []struct{ ... }
- func (mock *ClientMock) IsDirty() bool
- func (mock *ClientMock) IsDirtyCalls() []struct{}
- func (mock *ClientMock) IsInitialized() bool
- func (mock *ClientMock) IsInitializedCalls() []struct{}
- func (mock *ClientMock) IsInstalled() bool
- func (mock *ClientMock) IsInstalledCalls() []struct{}
- func (mock *ClientMock) StatusLines() ([]string, error)
- func (mock *ClientMock) StatusLinesCalls() []struct{}
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HasCommits ¶
func HasCommits() bool
HasCommits returns true if there are commits in the working dir.
func IsInitialized ¶
func IsInitialized() bool
IsInitialized returns true if the working dir has been initialized.
func StatusLines ¶
StatusLines returns the result of `git status --porcelain`.
Types ¶
type Client ¶
type Client interface {
// Exec executes git with args.
Exec(args ...string) (bytes.Buffer, bytes.Buffer, error)
// HasCommits returns true if there are commits in the working dir.
HasCommits() bool
// HasRemote returns true if name has been configured as a remote.
HasRemote(name string) bool
// IsDirty returns true if there are uncommitted files.
IsDirty() bool
// IsInitialized returns true if the working dir has been initialized.
IsInitialized() bool
// IsInstalled returns true if git is installed.
IsInstalled() bool
// StatusLines returns the result of `git status --porcelain`.
StatusLines() ([]string, error)
}
A git CLI client.
var ( // DefaultClient is the default Git client. DefaultClient Client = &systemClient{} )
type ClientMock ¶
type ClientMock struct {
// ExecFunc mocks the Exec method.
ExecFunc func(args ...string) (bytes.Buffer, bytes.Buffer, error)
// HasCommitsFunc mocks the HasCommits method.
HasCommitsFunc func() bool
// HasRemoteFunc mocks the HasRemote method.
HasRemoteFunc func(name string) bool
// IsDirtyFunc mocks the IsDirty method.
IsDirtyFunc func() bool
// IsInitializedFunc mocks the IsInitialized method.
IsInitializedFunc func() bool
// IsInstalledFunc mocks the IsInstalled method.
IsInstalledFunc func() bool
// StatusLinesFunc mocks the StatusLines method.
StatusLinesFunc func() ([]string, error)
// contains filtered or unexported fields
}
ClientMock is a mock implementation of Client.
func TestSomethingThatUsesClient(t *testing.T) {
// make and configure a mocked Client
mockedClient := &ClientMock{
ExecFunc: func(args ...string) (bytes.Buffer, bytes.Buffer, error) {
panic("mock out the Exec method")
},
HasCommitsFunc: func() bool {
panic("mock out the HasCommits method")
},
HasRemoteFunc: func(name string) bool {
panic("mock out the HasRemote method")
},
IsDirtyFunc: func() bool {
panic("mock out the IsDirty method")
},
IsInitializedFunc: func() bool {
panic("mock out the IsInitialized method")
},
IsInstalledFunc: func() bool {
panic("mock out the IsInstalled method")
},
StatusLinesFunc: func() ([]string, error) {
panic("mock out the StatusLines method")
},
}
// use mockedClient in code that requires Client
// and then make assertions.
}
func (*ClientMock) ExecCalls ¶
func (mock *ClientMock) ExecCalls() []struct { Args []string }
ExecCalls gets all the calls that were made to Exec. Check the length with:
len(mockedClient.ExecCalls())
func (*ClientMock) HasCommits ¶
func (mock *ClientMock) HasCommits() bool
HasCommits calls HasCommitsFunc.
func (*ClientMock) HasCommitsCalls ¶
func (mock *ClientMock) HasCommitsCalls() []struct { }
HasCommitsCalls gets all the calls that were made to HasCommits. Check the length with:
len(mockedClient.HasCommitsCalls())
func (*ClientMock) HasRemote ¶
func (mock *ClientMock) HasRemote(name string) bool
HasRemote calls HasRemoteFunc.
func (*ClientMock) HasRemoteCalls ¶
func (mock *ClientMock) HasRemoteCalls() []struct { Name string }
HasRemoteCalls gets all the calls that were made to HasRemote. Check the length with:
len(mockedClient.HasRemoteCalls())
func (*ClientMock) IsDirtyCalls ¶
func (mock *ClientMock) IsDirtyCalls() []struct { }
IsDirtyCalls gets all the calls that were made to IsDirty. Check the length with:
len(mockedClient.IsDirtyCalls())
func (*ClientMock) IsInitialized ¶
func (mock *ClientMock) IsInitialized() bool
IsInitialized calls IsInitializedFunc.
func (*ClientMock) IsInitializedCalls ¶
func (mock *ClientMock) IsInitializedCalls() []struct { }
IsInitializedCalls gets all the calls that were made to IsInitialized. Check the length with:
len(mockedClient.IsInitializedCalls())
func (*ClientMock) IsInstalled ¶
func (mock *ClientMock) IsInstalled() bool
IsInstalled calls IsInstalledFunc.
func (*ClientMock) IsInstalledCalls ¶
func (mock *ClientMock) IsInstalledCalls() []struct { }
IsInstalledCalls gets all the calls that were made to IsInstalled. Check the length with:
len(mockedClient.IsInstalledCalls())
func (*ClientMock) StatusLines ¶
func (mock *ClientMock) StatusLines() ([]string, error)
StatusLines calls StatusLinesFunc.
func (*ClientMock) StatusLinesCalls ¶
func (mock *ClientMock) StatusLinesCalls() []struct { }
StatusLinesCalls gets all the calls that were made to StatusLines. Check the length with:
len(mockedClient.StatusLinesCalls())