Documentation
¶
Index ¶
- type CreateParams
- type PullRequest
- type PullRequestProvider
- type PullRequestProviderMock
- func (mock *PullRequestProviderMock) AddLabels(pullRequest string, labels []string) error
- func (mock *PullRequestProviderMock) AddLabelsCalls() []struct{ ... }
- func (mock *PullRequestProviderMock) Create(createParams CreateParams) (string, error)
- func (mock *PullRequestProviderMock) CreateCalls() []struct{ ... }
- func (mock *PullRequestProviderMock) CreateInteractively(branch string) error
- func (mock *PullRequestProviderMock) CreateInteractivelyCalls() []struct{ ... }
- func (mock *PullRequestProviderMock) EnsureInstalledAndAuthenticated() error
- func (mock *PullRequestProviderMock) EnsureInstalledAndAuthenticatedCalls() []struct{}
- func (mock *PullRequestProviderMock) Exists(branch string) (bool, error)
- func (mock *PullRequestProviderMock) ExistsCalls() []struct{ ... }
- func (mock *PullRequestProviderMock) FetchHead(number int) error
- func (mock *PullRequestProviderMock) FetchHeadCalls() []struct{ ... }
- func (mock *PullRequestProviderMock) Get(pullRequest string) (*PullRequest, error)
- func (mock *PullRequestProviderMock) GetBranchesPromotingToEnvironment(env string) ([]string, error)
- func (mock *PullRequestProviderMock) GetBranchesPromotingToEnvironmentCalls() []struct{ ... }
- func (mock *PullRequestProviderMock) GetCalls() []struct{ ... }
- func (mock *PullRequestProviderMock) GetPromotionEnvironment(branch string) (string, error)
- func (mock *PullRequestProviderMock) GetPromotionEnvironmentCalls() []struct{ ... }
- func (mock *PullRequestProviderMock) List(search string, limit int) ([]PullRequest, error)
- func (mock *PullRequestProviderMock) ListCalls() []struct{ ... }
- func (mock *PullRequestProviderMock) SetPromotionEnvironment(branch string, env string) error
- func (mock *PullRequestProviderMock) SetPromotionEnvironmentCalls() []struct{ ... }
- func (mock *PullRequestProviderMock) Update(updateParams UpdateParams) (string, error)
- func (mock *PullRequestProviderMock) UpdateCalls() []struct{ ... }
- type UpdateParams
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateParams ¶ added in v0.22.0
type PullRequest ¶ added in v0.102.0
type PullRequest struct {
Number int
URL string
Branch string
Body string
Labels []string
Open bool
Approved bool
// Commits are the SHAs of the pull request commits, oldest first.
Commits []string
// HeadSHA is the SHA of the commit at the head of the pull request branch.
HeadSHA string
// CrossRepository is whether the pull request branch is in a fork rather than in the repository itself.
CrossRepository 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)
// Get returns the pull request referenced by given number, URL or branch, failing if it does not belong to the
// repository.
Get(pullRequest string) (*PullRequest, error)
// List returns up to limit pull requests in any state matching given search query, most recent first.
List(search string, limit int) ([]PullRequest, error)
// FetchHead fetches the commits of the pull request with given number into the local repository.
FetchHead(number int) error
// AddLabels adds given labels to the pull request referenced by given number, URL or branch.
AddLabels(pullRequest string, labels []string) error
// Update updates the title and body of an existing pull request, adding the given labels and reviewers, then
// removes the given labels only once that succeeded, and returns its URL.
Update(UpdateParams) (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 {
// AddLabelsFunc mocks the AddLabels method.
AddLabelsFunc func(pullRequest string, labels []string) error
// 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)
// FetchHeadFunc mocks the FetchHead method.
FetchHeadFunc func(number int) error
// GetFunc mocks the Get method.
GetFunc func(pullRequest string) (*PullRequest, error)
// GetBranchesPromotingToEnvironmentFunc mocks the GetBranchesPromotingToEnvironment method.
GetBranchesPromotingToEnvironmentFunc func(env string) ([]string, error)
// GetPromotionEnvironmentFunc mocks the GetPromotionEnvironment method.
GetPromotionEnvironmentFunc func(branch string) (string, error)
// ListFunc mocks the List method.
ListFunc func(search string, limit int) ([]PullRequest, error)
// SetPromotionEnvironmentFunc mocks the SetPromotionEnvironment method.
SetPromotionEnvironmentFunc func(branch string, env string) error
// UpdateFunc mocks the Update method.
UpdateFunc func(updateParams UpdateParams) (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{
AddLabelsFunc: func(pullRequest string, labels []string) error {
panic("mock out the AddLabels method")
},
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")
},
FetchHeadFunc: func(number int) error {
panic("mock out the FetchHead method")
},
GetFunc: func(pullRequest string) (*PullRequest, error) {
panic("mock out the Get 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")
},
ListFunc: func(search string, limit int) ([]PullRequest, error) {
panic("mock out the List method")
},
SetPromotionEnvironmentFunc: func(branch string, env string) error {
panic("mock out the SetPromotionEnvironment method")
},
UpdateFunc: func(updateParams UpdateParams) (string, error) {
panic("mock out the Update method")
},
}
// use mockedPullRequestProvider in code that requires PullRequestProvider
// and then make assertions.
}
func (*PullRequestProviderMock) AddLabels ¶ added in v0.102.0
func (mock *PullRequestProviderMock) AddLabels(pullRequest string, labels []string) error
AddLabels calls AddLabelsFunc.
func (*PullRequestProviderMock) AddLabelsCalls ¶ added in v0.102.0
func (mock *PullRequestProviderMock) AddLabelsCalls() []struct { PullRequest string Labels []string }
AddLabelsCalls gets all the calls that were made to AddLabels. Check the length with:
len(mockedPullRequestProvider.AddLabelsCalls())
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) FetchHead ¶ added in v0.102.0
func (mock *PullRequestProviderMock) FetchHead(number int) error
FetchHead calls FetchHeadFunc.
func (*PullRequestProviderMock) FetchHeadCalls ¶ added in v0.102.0
func (mock *PullRequestProviderMock) FetchHeadCalls() []struct { Number int }
FetchHeadCalls gets all the calls that were made to FetchHead. Check the length with:
len(mockedPullRequestProvider.FetchHeadCalls())
func (*PullRequestProviderMock) Get ¶ added in v0.102.0
func (mock *PullRequestProviderMock) Get(pullRequest string) (*PullRequest, error)
Get calls GetFunc.
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) GetCalls ¶ added in v0.102.0
func (mock *PullRequestProviderMock) GetCalls() []struct { PullRequest string }
GetCalls gets all the calls that were made to Get. Check the length with:
len(mockedPullRequestProvider.GetCalls())
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) List ¶ added in v0.102.0
func (mock *PullRequestProviderMock) List(search string, limit int) ([]PullRequest, error)
List calls ListFunc.
func (*PullRequestProviderMock) ListCalls ¶ added in v0.102.0
func (mock *PullRequestProviderMock) ListCalls() []struct { Search string Limit int }
ListCalls gets all the calls that were made to List. Check the length with:
len(mockedPullRequestProvider.ListCalls())
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())
func (*PullRequestProviderMock) Update ¶ added in v0.102.0
func (mock *PullRequestProviderMock) Update(updateParams UpdateParams) (string, error)
Update calls UpdateFunc.
func (*PullRequestProviderMock) UpdateCalls ¶ added in v0.102.0
func (mock *PullRequestProviderMock) UpdateCalls() []struct { UpdateParams UpdateParams }
UpdateCalls gets all the calls that were made to Update. Check the length with:
len(mockedPullRequestProvider.UpdateCalls())