common_mock

package
v0.0.0-...-318a3d5 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2023 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CredentialReaderMock

type CredentialReaderMock struct {
	// GetCredentialsFunc mocks the GetCredentials method.
	GetCredentialsFunc func(project string) (*common_models.GitCredentials, error)
	// contains filtered or unexported fields
}

CredentialReaderMock is a mock implementation of common.CredentialReader.

func TestSomethingThatUsesCredentialReader(t *testing.T) {

	// make and configure a mocked common.CredentialReader
	mockedCredentialReader := &CredentialReaderMock{
		GetCredentialsFunc: func(project string) (*common_models.GitCredentials, error) {
			panic("mock out the GetCredentials method")
		},
	}

	// use mockedCredentialReader in code that requires common.CredentialReader
	// and then make assertions.

}

func (*CredentialReaderMock) GetCredentials

func (mock *CredentialReaderMock) GetCredentials(project string) (*common_models.GitCredentials, error)

GetCredentials calls GetCredentialsFunc.

func (*CredentialReaderMock) GetCredentialsCalls

func (mock *CredentialReaderMock) GetCredentialsCalls() []struct {
	Project string
}

GetCredentialsCalls gets all the calls that were made to GetCredentials. Check the length with:

len(mockedCredentialReader.GetCredentialsCalls())

type GogitMock

type GogitMock struct {
	// PlainCloneFunc mocks the PlainClone method.
	PlainCloneFunc func(gitContext common_models.GitContext, path string, isBare bool, o *git.CloneOptions) (*git.Repository, error)

	// PlainInitFunc mocks the PlainInit method.
	PlainInitFunc func(path string, isBare bool) (*git.Repository, error)

	// PlainOpenFunc mocks the PlainOpen method.
	PlainOpenFunc func(path string) (*git.Repository, error)
	// contains filtered or unexported fields
}

GogitMock is a mock implementation of common.Gogit.

func TestSomethingThatUsesGogit(t *testing.T) {

	// make and configure a mocked common.Gogit
	mockedGogit := &GogitMock{
		PlainCloneFunc: func(gitContext common_models.GitContext, path string, isBare bool, o *git.CloneOptions) (*git.Repository, error) {
			panic("mock out the PlainClone method")
		},
		PlainInitFunc: func(path string, isBare bool) (*git.Repository, error) {
			panic("mock out the PlainInit method")
		},
		PlainOpenFunc: func(path string) (*git.Repository, error) {
			panic("mock out the PlainOpen method")
		},
	}

	// use mockedGogit in code that requires common.Gogit
	// and then make assertions.

}

func (*GogitMock) PlainClone

func (mock *GogitMock) PlainClone(gitContext common_models.GitContext, path string, isBare bool, o *git.CloneOptions) (*git.Repository, error)

PlainClone calls PlainCloneFunc.

func (*GogitMock) PlainCloneCalls

func (mock *GogitMock) PlainCloneCalls() []struct {
	GitContext common_models.GitContext
	Path       string
	IsBare     bool
	O          *git.CloneOptions
}

PlainCloneCalls gets all the calls that were made to PlainClone. Check the length with:

len(mockedGogit.PlainCloneCalls())

func (*GogitMock) PlainInit

func (mock *GogitMock) PlainInit(path string, isBare bool) (*git.Repository, error)

PlainInit calls PlainInitFunc.

func (*GogitMock) PlainInitCalls

func (mock *GogitMock) PlainInitCalls() []struct {
	Path   string
	IsBare bool
}

PlainInitCalls gets all the calls that were made to PlainInit. Check the length with:

len(mockedGogit.PlainInitCalls())

func (*GogitMock) PlainOpen

func (mock *GogitMock) PlainOpen(path string) (*git.Repository, error)

PlainOpen calls PlainOpenFunc.

func (*GogitMock) PlainOpenCalls

func (mock *GogitMock) PlainOpenCalls() []struct {
	Path string
}

PlainOpenCalls gets all the calls that were made to PlainOpen. Check the length with:

len(mockedGogit.PlainOpenCalls())

type IFileSystemMock

type IFileSystemMock struct {
	// DeleteFileFunc mocks the DeleteFile method.
	DeleteFileFunc func(path string) error

	// FileExistsFunc mocks the FileExists method.
	FileExistsFunc func(path string) bool

	// MakeDirFunc mocks the MakeDir method.
	MakeDirFunc func(path string) error

	// ReadFileFunc mocks the ReadFile method.
	ReadFileFunc func(filename string) ([]byte, error)

	// WalkPathFunc mocks the WalkPath method.
	WalkPathFunc func(path string, walkFunc filepath.WalkFunc) error

	// WriteBase64EncodedFileFunc mocks the WriteBase64EncodedFile method.
	WriteBase64EncodedFileFunc func(path string, content string) error

	// WriteFileFunc mocks the WriteFile method.
	WriteFileFunc func(path string, content []byte) error

	// WriteHelmChartFunc mocks the WriteHelmChart method.
	WriteHelmChartFunc func(path string) error
	// contains filtered or unexported fields
}

IFileSystemMock is a mock implementation of common.IFileSystem.

func TestSomethingThatUsesIFileSystem(t *testing.T) {

	// make and configure a mocked common.IFileSystem
	mockedIFileSystem := &IFileSystemMock{
		DeleteFileFunc: func(path string) error {
			panic("mock out the DeleteFile method")
		},
		FileExistsFunc: func(path string) bool {
			panic("mock out the FileExists method")
		},
		MakeDirFunc: func(path string) error {
			panic("mock out the MakeDir method")
		},
		ReadFileFunc: func(filename string) ([]byte, error) {
			panic("mock out the ReadFile method")
		},
		WalkPathFunc: func(path string, walkFunc filepath.WalkFunc) error {
			panic("mock out the WalkPath method")
		},
		WriteBase64EncodedFileFunc: func(path string, content string) error {
			panic("mock out the WriteBase64EncodedFile method")
		},
		WriteFileFunc: func(path string, content []byte) error {
			panic("mock out the WriteFile method")
		},
		WriteHelmChartFunc: func(path string) error {
			panic("mock out the WriteHelmChart method")
		},
	}

	// use mockedIFileSystem in code that requires common.IFileSystem
	// and then make assertions.

}

func (*IFileSystemMock) DeleteFile

func (mock *IFileSystemMock) DeleteFile(path string) error

DeleteFile calls DeleteFileFunc.

func (*IFileSystemMock) DeleteFileCalls

func (mock *IFileSystemMock) DeleteFileCalls() []struct {
	Path string
}

DeleteFileCalls gets all the calls that were made to DeleteFile. Check the length with:

len(mockedIFileSystem.DeleteFileCalls())

func (*IFileSystemMock) FileExists

func (mock *IFileSystemMock) FileExists(path string) bool

FileExists calls FileExistsFunc.

func (*IFileSystemMock) FileExistsCalls

func (mock *IFileSystemMock) FileExistsCalls() []struct {
	Path string
}

FileExistsCalls gets all the calls that were made to FileExists. Check the length with:

len(mockedIFileSystem.FileExistsCalls())

func (*IFileSystemMock) MakeDir

func (mock *IFileSystemMock) MakeDir(path string) error

MakeDir calls MakeDirFunc.

func (*IFileSystemMock) MakeDirCalls

func (mock *IFileSystemMock) MakeDirCalls() []struct {
	Path string
}

MakeDirCalls gets all the calls that were made to MakeDir. Check the length with:

len(mockedIFileSystem.MakeDirCalls())

func (*IFileSystemMock) ReadFile

func (mock *IFileSystemMock) ReadFile(filename string) ([]byte, error)

ReadFile calls ReadFileFunc.

func (*IFileSystemMock) ReadFileCalls

func (mock *IFileSystemMock) ReadFileCalls() []struct {
	Filename string
}

ReadFileCalls gets all the calls that were made to ReadFile. Check the length with:

len(mockedIFileSystem.ReadFileCalls())

func (*IFileSystemMock) WalkPath

func (mock *IFileSystemMock) WalkPath(path string, walkFunc filepath.WalkFunc) error

WalkPath calls WalkPathFunc.

func (*IFileSystemMock) WalkPathCalls

func (mock *IFileSystemMock) WalkPathCalls() []struct {
	Path     string
	WalkFunc filepath.WalkFunc
}

WalkPathCalls gets all the calls that were made to WalkPath. Check the length with:

len(mockedIFileSystem.WalkPathCalls())

func (*IFileSystemMock) WriteBase64EncodedFile

func (mock *IFileSystemMock) WriteBase64EncodedFile(path string, content string) error

WriteBase64EncodedFile calls WriteBase64EncodedFileFunc.

func (*IFileSystemMock) WriteBase64EncodedFileCalls

func (mock *IFileSystemMock) WriteBase64EncodedFileCalls() []struct {
	Path    string
	Content string
}

WriteBase64EncodedFileCalls gets all the calls that were made to WriteBase64EncodedFile. Check the length with:

len(mockedIFileSystem.WriteBase64EncodedFileCalls())

func (*IFileSystemMock) WriteFile

func (mock *IFileSystemMock) WriteFile(path string, content []byte) error

WriteFile calls WriteFileFunc.

func (*IFileSystemMock) WriteFileCalls

func (mock *IFileSystemMock) WriteFileCalls() []struct {
	Path    string
	Content []byte
}

WriteFileCalls gets all the calls that were made to WriteFile. Check the length with:

len(mockedIFileSystem.WriteFileCalls())

func (*IFileSystemMock) WriteHelmChart

func (mock *IFileSystemMock) WriteHelmChart(path string) error

WriteHelmChart calls WriteHelmChartFunc.

func (*IFileSystemMock) WriteHelmChartCalls

func (mock *IFileSystemMock) WriteHelmChartCalls() []struct {
	Path string
}

WriteHelmChartCalls gets all the calls that were made to WriteHelmChart. Check the length with:

len(mockedIFileSystem.WriteHelmChartCalls())

type IGitMock

type IGitMock struct {
	// CheckUpstreamConnectionFunc mocks the CheckUpstreamConnection method.
	CheckUpstreamConnectionFunc func(gitContext common_models.GitContext) error

	// CheckoutBranchFunc mocks the CheckoutBranch method.
	CheckoutBranchFunc func(gitContext common_models.GitContext, branch string) error

	// CloneRepoFunc mocks the CloneRepo method.
	CloneRepoFunc func(gitContext common_models.GitContext) (bool, error)

	// CreateBranchFunc mocks the CreateBranch method.
	CreateBranchFunc func(gitContext common_models.GitContext, branch string, sourceBranch string) error

	// GetCurrentRevisionFunc mocks the GetCurrentRevision method.
	GetCurrentRevisionFunc func(gitContext common_models.GitContext) (string, error)

	// GetDefaultBranchFunc mocks the GetDefaultBranch method.
	GetDefaultBranchFunc func(gitContext common_models.GitContext) (string, error)

	// GetFileRevisionFunc mocks the GetFileRevision method.
	GetFileRevisionFunc func(gitContext common_models.GitContext, revision string, file string) ([]byte, error)

	// MigrateProjectFunc mocks the MigrateProject method.
	MigrateProjectFunc func(gitContext common_models.GitContext, newMetadatacontent []byte) error

	// MoveToNewUpstreamFunc mocks the MoveToNewUpstream method.
	MoveToNewUpstreamFunc func(currentContext common_models.GitContext, newContext common_models.GitContext) error

	// ProjectExistsFunc mocks the ProjectExists method.
	ProjectExistsFunc func(gitContext common_models.GitContext) bool

	// ProjectRepoExistsFunc mocks the ProjectRepoExists method.
	ProjectRepoExistsFunc func(projectName string) bool

	// PullFunc mocks the Pull method.
	PullFunc func(gitContext common_models.GitContext) error

	// PushFunc mocks the Push method.
	PushFunc func(gitContext common_models.GitContext) error

	// ResetHardFunc mocks the ResetHard method.
	ResetHardFunc func(gitContext common_models.GitContext, revision string) error

	// StageAndCommitAllFunc mocks the StageAndCommitAll method.
	StageAndCommitAllFunc func(gitContext common_models.GitContext, message string) (string, error)
	// contains filtered or unexported fields
}

IGitMock is a mock implementation of common.IGit.

func TestSomethingThatUsesIGit(t *testing.T) {

	// make and configure a mocked common.IGit
	mockedIGit := &IGitMock{
		CheckUpstreamConnectionFunc: func(gitContext common_models.GitContext) error {
			panic("mock out the CheckUpstreamConnection method")
		},
		CheckoutBranchFunc: func(gitContext common_models.GitContext, branch string) error {
			panic("mock out the CheckoutBranch method")
		},
		CloneRepoFunc: func(gitContext common_models.GitContext) (bool, error) {
			panic("mock out the CloneRepo method")
		},
		CreateBranchFunc: func(gitContext common_models.GitContext, branch string, sourceBranch string) error {
			panic("mock out the CreateBranch method")
		},
		GetCurrentRevisionFunc: func(gitContext common_models.GitContext) (string, error) {
			panic("mock out the GetCurrentRevision method")
		},
		GetDefaultBranchFunc: func(gitContext common_models.GitContext) (string, error) {
			panic("mock out the GetDefaultBranch method")
		},
		GetFileRevisionFunc: func(gitContext common_models.GitContext, revision string, file string) ([]byte, error) {
			panic("mock out the GetFileRevision method")
		},
		MigrateProjectFunc: func(gitContext common_models.GitContext, newMetadatacontent []byte) error {
			panic("mock out the MigrateProject method")
		},
		MoveToNewUpstreamFunc: func(currentContext common_models.GitContext, newContext common_models.GitContext) error {
			panic("mock out the MoveToNewUpstream method")
		},
		ProjectExistsFunc: func(gitContext common_models.GitContext) bool {
			panic("mock out the ProjectExists method")
		},
		ProjectRepoExistsFunc: func(projectName string) bool {
			panic("mock out the ProjectRepoExists method")
		},
		PullFunc: func(gitContext common_models.GitContext) error {
			panic("mock out the Pull method")
		},
		PushFunc: func(gitContext common_models.GitContext) error {
			panic("mock out the Push method")
		},
		ResetHardFunc: func(gitContext common_models.GitContext, revision string) error {
			panic("mock out the ResetHard method")
		},
		StageAndCommitAllFunc: func(gitContext common_models.GitContext, message string) (string, error) {
			panic("mock out the StageAndCommitAll method")
		},
	}

	// use mockedIGit in code that requires common.IGit
	// and then make assertions.

}

func (*IGitMock) CheckUpstreamConnection

func (mock *IGitMock) CheckUpstreamConnection(gitContext common_models.GitContext) error

CheckUpstreamConnection calls CheckUpstreamConnectionFunc.

func (*IGitMock) CheckUpstreamConnectionCalls

func (mock *IGitMock) CheckUpstreamConnectionCalls() []struct {
	GitContext common_models.GitContext
}

CheckUpstreamConnectionCalls gets all the calls that were made to CheckUpstreamConnection. Check the length with:

len(mockedIGit.CheckUpstreamConnectionCalls())

func (*IGitMock) CheckoutBranch

func (mock *IGitMock) CheckoutBranch(gitContext common_models.GitContext, branch string) error

CheckoutBranch calls CheckoutBranchFunc.

func (*IGitMock) CheckoutBranchCalls

func (mock *IGitMock) CheckoutBranchCalls() []struct {
	GitContext common_models.GitContext
	Branch     string
}

CheckoutBranchCalls gets all the calls that were made to CheckoutBranch. Check the length with:

len(mockedIGit.CheckoutBranchCalls())

func (*IGitMock) CloneRepo

func (mock *IGitMock) CloneRepo(gitContext common_models.GitContext) (bool, error)

CloneRepo calls CloneRepoFunc.

func (*IGitMock) CloneRepoCalls

func (mock *IGitMock) CloneRepoCalls() []struct {
	GitContext common_models.GitContext
}

CloneRepoCalls gets all the calls that were made to CloneRepo. Check the length with:

len(mockedIGit.CloneRepoCalls())

func (*IGitMock) CreateBranch

func (mock *IGitMock) CreateBranch(gitContext common_models.GitContext, branch string, sourceBranch string) error

CreateBranch calls CreateBranchFunc.

func (*IGitMock) CreateBranchCalls

func (mock *IGitMock) CreateBranchCalls() []struct {
	GitContext   common_models.GitContext
	Branch       string
	SourceBranch string
}

CreateBranchCalls gets all the calls that were made to CreateBranch. Check the length with:

len(mockedIGit.CreateBranchCalls())

func (*IGitMock) GetCurrentRevision

func (mock *IGitMock) GetCurrentRevision(gitContext common_models.GitContext) (string, error)

GetCurrentRevision calls GetCurrentRevisionFunc.

func (*IGitMock) GetCurrentRevisionCalls

func (mock *IGitMock) GetCurrentRevisionCalls() []struct {
	GitContext common_models.GitContext
}

GetCurrentRevisionCalls gets all the calls that were made to GetCurrentRevision. Check the length with:

len(mockedIGit.GetCurrentRevisionCalls())

func (*IGitMock) GetDefaultBranch

func (mock *IGitMock) GetDefaultBranch(gitContext common_models.GitContext) (string, error)

GetDefaultBranch calls GetDefaultBranchFunc.

func (*IGitMock) GetDefaultBranchCalls

func (mock *IGitMock) GetDefaultBranchCalls() []struct {
	GitContext common_models.GitContext
}

GetDefaultBranchCalls gets all the calls that were made to GetDefaultBranch. Check the length with:

len(mockedIGit.GetDefaultBranchCalls())

func (*IGitMock) GetFileRevision

func (mock *IGitMock) GetFileRevision(gitContext common_models.GitContext, revision string, file string) ([]byte, error)

GetFileRevision calls GetFileRevisionFunc.

func (*IGitMock) GetFileRevisionCalls

func (mock *IGitMock) GetFileRevisionCalls() []struct {
	GitContext common_models.GitContext
	Revision   string
	File       string
}

GetFileRevisionCalls gets all the calls that were made to GetFileRevision. Check the length with:

len(mockedIGit.GetFileRevisionCalls())

func (*IGitMock) MigrateProject

func (mock *IGitMock) MigrateProject(gitContext common_models.GitContext, newMetadatacontent []byte) error

MigrateProject calls MigrateProjectFunc.

func (*IGitMock) MigrateProjectCalls

func (mock *IGitMock) MigrateProjectCalls() []struct {
	GitContext         common_models.GitContext
	NewMetadatacontent []byte
}

MigrateProjectCalls gets all the calls that were made to MigrateProject. Check the length with:

len(mockedIGit.MigrateProjectCalls())

func (*IGitMock) MoveToNewUpstream

func (mock *IGitMock) MoveToNewUpstream(currentContext common_models.GitContext, newContext common_models.GitContext) error

MoveToNewUpstream calls MoveToNewUpstreamFunc.

func (*IGitMock) MoveToNewUpstreamCalls

func (mock *IGitMock) MoveToNewUpstreamCalls() []struct {
	CurrentContext common_models.GitContext
	NewContext     common_models.GitContext
}

MoveToNewUpstreamCalls gets all the calls that were made to MoveToNewUpstream. Check the length with:

len(mockedIGit.MoveToNewUpstreamCalls())

func (*IGitMock) ProjectExists

func (mock *IGitMock) ProjectExists(gitContext common_models.GitContext) bool

ProjectExists calls ProjectExistsFunc.

func (*IGitMock) ProjectExistsCalls

func (mock *IGitMock) ProjectExistsCalls() []struct {
	GitContext common_models.GitContext
}

ProjectExistsCalls gets all the calls that were made to ProjectExists. Check the length with:

len(mockedIGit.ProjectExistsCalls())

func (*IGitMock) ProjectRepoExists

func (mock *IGitMock) ProjectRepoExists(projectName string) bool

ProjectRepoExists calls ProjectRepoExistsFunc.

func (*IGitMock) ProjectRepoExistsCalls

func (mock *IGitMock) ProjectRepoExistsCalls() []struct {
	ProjectName string
}

ProjectRepoExistsCalls gets all the calls that were made to ProjectRepoExists. Check the length with:

len(mockedIGit.ProjectRepoExistsCalls())

func (*IGitMock) Pull

func (mock *IGitMock) Pull(gitContext common_models.GitContext) error

Pull calls PullFunc.

func (*IGitMock) PullCalls

func (mock *IGitMock) PullCalls() []struct {
	GitContext common_models.GitContext
}

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

len(mockedIGit.PullCalls())

func (*IGitMock) Push

func (mock *IGitMock) Push(gitContext common_models.GitContext) error

Push calls PushFunc.

func (*IGitMock) PushCalls

func (mock *IGitMock) PushCalls() []struct {
	GitContext common_models.GitContext
}

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

len(mockedIGit.PushCalls())

func (*IGitMock) ResetHard

func (mock *IGitMock) ResetHard(gitContext common_models.GitContext, revision string) error

ResetHard calls ResetHardFunc.

func (*IGitMock) ResetHardCalls

func (mock *IGitMock) ResetHardCalls() []struct {
	GitContext common_models.GitContext
	Revision   string
}

ResetHardCalls gets all the calls that were made to ResetHard. Check the length with:

len(mockedIGit.ResetHardCalls())

func (*IGitMock) StageAndCommitAll

func (mock *IGitMock) StageAndCommitAll(gitContext common_models.GitContext, message string) (string, error)

StageAndCommitAll calls StageAndCommitAllFunc.

func (*IGitMock) StageAndCommitAllCalls

func (mock *IGitMock) StageAndCommitAllCalls() []struct {
	GitContext common_models.GitContext
	Message    string
}

StageAndCommitAllCalls gets all the calls that were made to StageAndCommitAll. Check the length with:

len(mockedIGit.StageAndCommitAllCalls())

Jump to

Keyboard shortcuts

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