gitclient

package
v0.0.0-...-7610aa1 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StubGitRepository

func StubGitRepository(t *testing.T) string

Types

type Client

type Client struct {
	GitPath string

	Stdout io.Writer
}

client implements GitClient

func (*Client) CreateBranchWithCheckout

func (c *Client) CreateBranchWithCheckout(branchName string) error

CreateBranchWithCheckout creates a new branch in current directory and does a checkout to that branch. All local changes will be preserved. If current directory is not a git repo, error is returned

type GitClient

type GitClient interface {
	CreateBranchWithCheckout(string) error
}

func NewClient

func NewClient(path string, iostream *iostreams.IOStream) GitClient

type GitClientMock

type GitClientMock struct {
	// CreateBranchWithCheckoutFunc mocks the CreateBranchWithCheckout method.
	CreateBranchWithCheckoutFunc func(s string) error
	// contains filtered or unexported fields
}

GitClientMock is a mock implementation of GitClient.

func TestSomethingThatUsesGitClient(t *testing.T) {

	// make and configure a mocked GitClient
	mockedGitClient := &GitClientMock{
		CreateBranchWithCheckoutFunc: func(s string) error {
			panic("mock out the CreateBranchWithCheckout method")
		},
	}

	// use mockedGitClient in code that requires GitClient
	// and then make assertions.

}

func NewGitClientMock

func NewGitClientMock() *GitClientMock

func (*GitClientMock) CreateBranchWithCheckout

func (mock *GitClientMock) CreateBranchWithCheckout(s string) error

CreateBranchWithCheckout calls CreateBranchWithCheckoutFunc.

func (*GitClientMock) CreateBranchWithCheckoutCalls

func (mock *GitClientMock) CreateBranchWithCheckoutCalls() []struct {
	S string
}

CreateBranchWithCheckoutCalls gets all the calls that were made to CreateBranchWithCheckout. Check the length with:

len(mockedGitClient.CreateBranchWithCheckoutCalls())

Jump to

Keyboard shortcuts

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