mock

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Repository

type Repository struct {
	CommitErr error

	DeleteErr error
	// contains filtered or unexported fields
}

func New

func New(localPath string, branches ...string) *Repository

New creates and returns a new git.Cache implementation that operates entirely in-memory.

func (*Repository) AddFiles

func (m *Repository) AddFiles(names ...string)

AddFiles is part of the mock implementation, it records filenames so that they're used in the Walk implementation.

func (*Repository) AssertBranchCreated

func (m *Repository) AssertBranchCreated(t *testing.T, from, name string)

AssertBranchCreated asserts that the named branch was created from the from branch, using the `CheckoutAndCreate` implementation.

func (*Repository) AssertBranchNotCreated added in v0.2.1

func (m *Repository) AssertBranchNotCreated(t *testing.T, from, name string)

AssertBranchNotCreated asserts that the named branch was *not* created from the from branch, using the `CheckoutAndCreate` implementation.

func (*Repository) AssertCommit

func (m *Repository) AssertCommit(t *testing.T, branch, msg string, a *git.Author)

AssertCommit asserts that a commit was created for the named branch with the message and auth token.

func (*Repository) AssertDeletedFromCache

func (m *Repository) AssertDeletedFromCache(t *testing.T)

AssertDeletedFromCache asserts that delete was called to remove the local repo

func (*Repository) AssertFileCopiedInBranch

func (m *Repository) AssertFileCopiedInBranch(t *testing.T, branch, from, name string)

AssertFileCopiedInBranch asserts the filename was copied from and to in a branch.

func (*Repository) AssertFileNotCopiedInBranch added in v0.2.1

func (m *Repository) AssertFileNotCopiedInBranch(t *testing.T, branch, from, name string)

AssertFileNotCopiedInBranch asserts the filename was *not* copied from and to in a branch.

func (*Repository) AssertNotDeletedFromCache

func (m *Repository) AssertNotDeletedFromCache(t *testing.T)

AssertNotDeletedFromCache asserts that delete was called to remove the local repo

func (*Repository) AssertPush

func (m *Repository) AssertPush(t *testing.T, branch string)

AssertPush asserts that the branch was pushed.

func (*Repository) Checkout

func (m *Repository) Checkout(branch string) error

Checkout fulfils the git.Repo interface.

func (*Repository) CheckoutAndCreate

func (m *Repository) CheckoutAndCreate(branch string) error

CheckoutAndCreate fulfils the git.Repo interface.

func (*Repository) Clone

func (m *Repository) Clone() error

Clone fulfils the git.Repo interface.

func (*Repository) Commit

func (m *Repository) Commit(msg string, author *git.Author) error

Commit fulfils the git.Repo interface.

func (*Repository) CopyFile

func (m *Repository) CopyFile(src, dst string) error

CopyFile fulfils the git.Repo interface.

func (*Repository) DeleteCache

func (m *Repository) DeleteCache() error

DeleteCache deletes the repo from the local cache directory.

func (*Repository) DirectoriesUnderPath added in v0.2.1

func (m *Repository) DirectoriesUnderPath(path string) ([]os.FileInfo, error)

func (*Repository) GetCommitID

func (m *Repository) GetCommitID() string

func (*Repository) GetName

func (m *Repository) GetName() string

func (*Repository) GetUniqueEnvironmentFolder added in v0.2.1

func (m *Repository) GetUniqueEnvironmentFolder() (string, error)

func (*Repository) Push

func (m *Repository) Push(branch string) error

Push fulfils the git.Repo interface.

func (*Repository) StageFiles

func (m *Repository) StageFiles(filenames ...string) error

StageFiles fulfils the git.Repo interface.

func (*Repository) Walk

func (m *Repository) Walk(base string, cb func(string, string) error) error

Walk fulfils the git.Repo interface. It's a mock function to emulate what happens in Repository.Walk() The Mock version is different: it iterates over mockSource.files[] and then drives the visitor callback in CopyService() as usual.

To preserve the same behaviour, we see that Repository Walk receives /full/path/to/repo/services/service-name and then calls filePath.Walk() on /full/path/to/repo/services/ . When CopyService() drives Walk(), 'base' is typically services/service-name Thus we take each /full/path/to/file/in/mockSource.files[] and split it at 'services/' as happens in the Walk() method we're mocking.

func (*Repository) WriteFile

func (m *Repository) WriteFile(src io.Reader, dst string) error

WriteFile fulfils the git.Repo interface.

Jump to

Keyboard shortcuts

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