pr

package
v0.55.1 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2024 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateParams added in v0.22.0

type CreateParams struct {
	Branch    string
	Title     string
	Body      string
	Labels    []string
	Reviewers []string
	Draft     bool
}

type PullRequestProvider

type PullRequestProvider interface {
	// EnsureInstalledAndAuthenticated ensures the service provider is installed and authorized.
	EnsureInstalledAndAuthenticated() error

	// Exists returns whether a pull request exists for given branch.
	Exists(branch string) (bool, error)

	// GetBranchesPromotingToEnvironment returns the branches with pull requests configured for auto-promotion
	// to given environment.
	GetBranchesPromotingToEnvironment(env string) ([]string, error)

	// CreateInteractively prompts user to create a pull request for given branch.
	CreateInteractively(branch string) error

	// Create creates a pull request for given branch
	Create(CreateParams) (string, error)

	// GetPromotionEnvironment returns the environment to promote builds of given branch's pull request to.
	// If empty string is returned, promotion is disabled.
	GetPromotionEnvironment(branch string) (string, error)

	// SetPromotionEnvironment sets the environment to promote builds of given branch's pull request to.
	// Pass empty string to disable promotion.
	SetPromotionEnvironment(branch, env string) error
}

type PullRequestProviderMock added in v0.45.1

type PullRequestProviderMock struct {
	// CreateFunc mocks the Create method.
	CreateFunc func(createParams CreateParams) (string, error)

	// CreateInteractivelyFunc mocks the CreateInteractively method.
	CreateInteractivelyFunc func(branch string) error

	// EnsureInstalledAndAuthenticatedFunc mocks the EnsureInstalledAndAuthenticated method.
	EnsureInstalledAndAuthenticatedFunc func() error

	// ExistsFunc mocks the Exists method.
	ExistsFunc func(branch string) (bool, error)

	// GetBranchesPromotingToEnvironmentFunc mocks the GetBranchesPromotingToEnvironment method.
	GetBranchesPromotingToEnvironmentFunc func(env string) ([]string, error)

	// GetPromotionEnvironmentFunc mocks the GetPromotionEnvironment method.
	GetPromotionEnvironmentFunc func(branch string) (string, error)

	// SetPromotionEnvironmentFunc mocks the SetPromotionEnvironment method.
	SetPromotionEnvironmentFunc func(branch string, env string) error
	// contains filtered or unexported fields
}

PullRequestProviderMock is a mock implementation of PullRequestProvider.

func TestSomethingThatUsesPullRequestProvider(t *testing.T) {

	// make and configure a mocked PullRequestProvider
	mockedPullRequestProvider := &PullRequestProviderMock{
		CreateFunc: func(createParams CreateParams) (string, error) {
			panic("mock out the Create method")
		},
		CreateInteractivelyFunc: func(branch string) error {
			panic("mock out the CreateInteractively method")
		},
		EnsureInstalledAndAuthenticatedFunc: func() error {
			panic("mock out the EnsureInstalledAndAuthenticated method")
		},
		ExistsFunc: func(branch string) (bool, error) {
			panic("mock out the Exists method")
		},
		GetBranchesPromotingToEnvironmentFunc: func(env string) ([]string, error) {
			panic("mock out the GetBranchesPromotingToEnvironment method")
		},
		GetPromotionEnvironmentFunc: func(branch string) (string, error) {
			panic("mock out the GetPromotionEnvironment method")
		},
		SetPromotionEnvironmentFunc: func(branch string, env string) error {
			panic("mock out the SetPromotionEnvironment method")
		},
	}

	// use mockedPullRequestProvider in code that requires PullRequestProvider
	// and then make assertions.

}

func (*PullRequestProviderMock) Create added in v0.45.1

func (mock *PullRequestProviderMock) Create(createParams CreateParams) (string, error)

Create calls CreateFunc.

func (*PullRequestProviderMock) CreateCalls added in v0.45.1

func (mock *PullRequestProviderMock) CreateCalls() []struct {
	CreateParams CreateParams
}

CreateCalls gets all the calls that were made to Create. Check the length with:

len(mockedPullRequestProvider.CreateCalls())

func (*PullRequestProviderMock) CreateInteractively added in v0.45.1

func (mock *PullRequestProviderMock) CreateInteractively(branch string) error

CreateInteractively calls CreateInteractivelyFunc.

func (*PullRequestProviderMock) CreateInteractivelyCalls added in v0.45.1

func (mock *PullRequestProviderMock) CreateInteractivelyCalls() []struct {
	Branch string
}

CreateInteractivelyCalls gets all the calls that were made to CreateInteractively. Check the length with:

len(mockedPullRequestProvider.CreateInteractivelyCalls())

func (*PullRequestProviderMock) EnsureInstalledAndAuthenticated added in v0.45.1

func (mock *PullRequestProviderMock) EnsureInstalledAndAuthenticated() error

EnsureInstalledAndAuthenticated calls EnsureInstalledAndAuthenticatedFunc.

func (*PullRequestProviderMock) EnsureInstalledAndAuthenticatedCalls added in v0.45.1

func (mock *PullRequestProviderMock) EnsureInstalledAndAuthenticatedCalls() []struct {
}

EnsureInstalledAndAuthenticatedCalls gets all the calls that were made to EnsureInstalledAndAuthenticated. Check the length with:

len(mockedPullRequestProvider.EnsureInstalledAndAuthenticatedCalls())

func (*PullRequestProviderMock) Exists added in v0.45.1

func (mock *PullRequestProviderMock) Exists(branch string) (bool, error)

Exists calls ExistsFunc.

func (*PullRequestProviderMock) ExistsCalls added in v0.45.1

func (mock *PullRequestProviderMock) ExistsCalls() []struct {
	Branch string
}

ExistsCalls gets all the calls that were made to Exists. Check the length with:

len(mockedPullRequestProvider.ExistsCalls())

func (*PullRequestProviderMock) GetBranchesPromotingToEnvironment added in v0.45.1

func (mock *PullRequestProviderMock) GetBranchesPromotingToEnvironment(env string) ([]string, error)

GetBranchesPromotingToEnvironment calls GetBranchesPromotingToEnvironmentFunc.

func (*PullRequestProviderMock) GetBranchesPromotingToEnvironmentCalls added in v0.45.1

func (mock *PullRequestProviderMock) GetBranchesPromotingToEnvironmentCalls() []struct {
	Env string
}

GetBranchesPromotingToEnvironmentCalls gets all the calls that were made to GetBranchesPromotingToEnvironment. Check the length with:

len(mockedPullRequestProvider.GetBranchesPromotingToEnvironmentCalls())

func (*PullRequestProviderMock) GetPromotionEnvironment added in v0.45.1

func (mock *PullRequestProviderMock) GetPromotionEnvironment(branch string) (string, error)

GetPromotionEnvironment calls GetPromotionEnvironmentFunc.

func (*PullRequestProviderMock) GetPromotionEnvironmentCalls added in v0.45.1

func (mock *PullRequestProviderMock) GetPromotionEnvironmentCalls() []struct {
	Branch string
}

GetPromotionEnvironmentCalls gets all the calls that were made to GetPromotionEnvironment. Check the length with:

len(mockedPullRequestProvider.GetPromotionEnvironmentCalls())

func (*PullRequestProviderMock) SetPromotionEnvironment added in v0.45.1

func (mock *PullRequestProviderMock) SetPromotionEnvironment(branch string, env string) error

SetPromotionEnvironment calls SetPromotionEnvironmentFunc.

func (*PullRequestProviderMock) SetPromotionEnvironmentCalls added in v0.45.1

func (mock *PullRequestProviderMock) SetPromotionEnvironmentCalls() []struct {
	Branch string
	Env    string
}

SetPromotionEnvironmentCalls gets all the calls that were made to SetPromotionEnvironment. Check the length with:

len(mockedPullRequestProvider.SetPromotionEnvironmentCalls())

Jump to

Keyboard shortcuts

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