Merge branch 'trunk' into kw/gh-cli-epic-900-actors-are-assignable
This commit is contained in:
commit
d932934119
3 changed files with 92 additions and 5 deletions
|
|
@ -34,7 +34,7 @@ import (
|
|||
// but doesn't mandate that prompts always look exactly the same.
|
||||
func TestAccessiblePrompter(t *testing.T) {
|
||||
|
||||
beforePasswordSendTimeout := 20 * time.Microsecond
|
||||
beforePasswordSendTimeout := 100 * time.Microsecond
|
||||
|
||||
t.Run("Select", func(t *testing.T) {
|
||||
console := newTestVirtualTerminal(t)
|
||||
|
|
|
|||
|
|
@ -321,8 +321,7 @@ func updatePullRequestReviews(httpClient *http.Client, repo ghrepo.Interface, id
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (userIds == nil || len(*userIds) == 0) &&
|
||||
(teamIds == nil || len(*teamIds) == 0) {
|
||||
if userIds == nil && teamIds == nil {
|
||||
return nil
|
||||
}
|
||||
union := githubv4.Boolean(false)
|
||||
|
|
|
|||
|
|
@ -456,6 +456,67 @@ func Test_editRun(t *testing.T) {
|
|||
},
|
||||
stdout: "https://github.com/OWNER/REPO/pull/123\n",
|
||||
},
|
||||
{
|
||||
name: "non-interactive remove all reviewers",
|
||||
input: &EditOptions{
|
||||
SelectorArg: "123",
|
||||
Finder: shared.NewMockFinder("123", &api.PullRequest{
|
||||
URL: "https://github.com/OWNER/REPO/pull/123",
|
||||
}, ghrepo.New("OWNER", "REPO")),
|
||||
Interactive: false,
|
||||
Editable: shared.Editable{
|
||||
Title: shared.EditableString{
|
||||
Value: "new title",
|
||||
Edited: true,
|
||||
},
|
||||
Body: shared.EditableString{
|
||||
Value: "new body",
|
||||
Edited: true,
|
||||
},
|
||||
Base: shared.EditableString{
|
||||
Value: "base-branch-name",
|
||||
Edited: true,
|
||||
},
|
||||
Reviewers: shared.EditableSlice{
|
||||
Remove: []string{"OWNER/core", "OWNER/external", "monalisa", "hubot", "dependabot"},
|
||||
Edited: true,
|
||||
},
|
||||
Assignees: shared.EditableAssignees{
|
||||
EditableSlice: shared.EditableSlice{
|
||||
Add: []string{"monalisa", "hubot"},
|
||||
Remove: []string{"octocat"},
|
||||
Edited: true,
|
||||
},
|
||||
},
|
||||
Labels: shared.EditableSlice{
|
||||
Add: []string{"feature", "TODO", "bug"},
|
||||
Remove: []string{"docs"},
|
||||
Edited: true,
|
||||
},
|
||||
Projects: shared.EditableProjects{
|
||||
EditableSlice: shared.EditableSlice{
|
||||
Add: []string{"Cleanup", "CleanupV2"},
|
||||
Remove: []string{"Roadmap", "RoadmapV2"},
|
||||
Edited: true,
|
||||
},
|
||||
},
|
||||
Milestone: shared.EditableString{
|
||||
Value: "GA",
|
||||
Edited: true,
|
||||
},
|
||||
},
|
||||
Fetcher: testFetcher{},
|
||||
},
|
||||
httpStubs: func(reg *httpmock.Registry) {
|
||||
mockRepoMetadata(reg, false)
|
||||
mockPullRequestUpdate(reg)
|
||||
mockPullRequestReviewersUpdate(reg)
|
||||
mockPullRequestUpdateLabels(reg)
|
||||
mockPullRequestUpdateActorAssignees(reg)
|
||||
mockProjectV2ItemUpdate(reg)
|
||||
},
|
||||
stdout: "https://github.com/OWNER/REPO/pull/123\n",
|
||||
},
|
||||
{
|
||||
name: "interactive",
|
||||
input: &EditOptions{
|
||||
|
|
@ -499,6 +560,28 @@ func Test_editRun(t *testing.T) {
|
|||
},
|
||||
stdout: "https://github.com/OWNER/REPO/pull/123\n",
|
||||
},
|
||||
{
|
||||
name: "interactive remove all reviewers",
|
||||
input: &EditOptions{
|
||||
SelectorArg: "123",
|
||||
Finder: shared.NewMockFinder("123", &api.PullRequest{
|
||||
URL: "https://github.com/OWNER/REPO/pull/123",
|
||||
}, ghrepo.New("OWNER", "REPO")),
|
||||
Interactive: true,
|
||||
Surveyor: testSurveyor{removeAllReviewers: true},
|
||||
Fetcher: testFetcher{},
|
||||
EditorRetriever: testEditorRetriever{},
|
||||
},
|
||||
httpStubs: func(reg *httpmock.Registry) {
|
||||
mockRepoMetadata(reg, false)
|
||||
mockPullRequestUpdate(reg)
|
||||
mockPullRequestReviewersUpdate(reg)
|
||||
mockPullRequestUpdateActorAssignees(reg)
|
||||
mockPullRequestUpdateLabels(reg)
|
||||
mockProjectV2ItemUpdate(reg)
|
||||
},
|
||||
stdout: "https://github.com/OWNER/REPO/pull/123\n",
|
||||
},
|
||||
{
|
||||
name: "Legacy assignee users are fetched and updated on unsupported GitHub Hosts",
|
||||
input: &EditOptions{
|
||||
|
|
@ -719,7 +802,8 @@ func mockProjectV2ItemUpdate(reg *httpmock.Registry) {
|
|||
|
||||
type testFetcher struct{}
|
||||
type testSurveyor struct {
|
||||
skipReviewers bool
|
||||
skipReviewers bool
|
||||
removeAllReviewers bool
|
||||
}
|
||||
type testEditorRetriever struct{}
|
||||
|
||||
|
|
@ -744,7 +828,11 @@ func (s testSurveyor) EditFields(e *shared.Editable, _ string) error {
|
|||
e.Title.Value = "new title"
|
||||
e.Body.Value = "new body"
|
||||
if !s.skipReviewers {
|
||||
e.Reviewers.Value = []string{"monalisa", "hubot", "OWNER/core", "OWNER/external"}
|
||||
if s.removeAllReviewers {
|
||||
e.Reviewers.Remove = []string{"monalisa", "hubot", "OWNER/core", "OWNER/external", "dependabot"}
|
||||
} else {
|
||||
e.Reviewers.Value = []string{"monalisa", "hubot", "OWNER/core", "OWNER/external"}
|
||||
}
|
||||
}
|
||||
e.Assignees.Value = []string{"monalisa", "hubot"}
|
||||
e.Labels.Value = []string{"feature", "TODO", "bug"}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue