test for forking in org
This commit is contained in:
parent
3e2f09d970
commit
480505511c
2 changed files with 51 additions and 9 deletions
|
|
@ -10,7 +10,6 @@ import (
|
|||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/AlecAivazis/survey/v2"
|
||||
"github.com/MakeNowJust/heredoc"
|
||||
"github.com/cli/cli/v2/api"
|
||||
fd "github.com/cli/cli/v2/internal/featuredetection"
|
||||
|
|
@ -19,7 +18,6 @@ import (
|
|||
"github.com/cli/cli/v2/internal/prompter"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
"github.com/cli/cli/v2/pkg/iostreams"
|
||||
"github.com/cli/cli/v2/pkg/prompt"
|
||||
"github.com/cli/cli/v2/pkg/set"
|
||||
"github.com/spf13/cobra"
|
||||
"golang.org/x/sync/errgroup"
|
||||
|
|
@ -446,15 +444,13 @@ func interactiveRepoEdit(opts *EditOptions, r *api.Repository) error {
|
|||
}
|
||||
opts.Edits.IsTemplate = &c
|
||||
case optionAllowForking:
|
||||
opts.Edits.AllowForking = &r.ForkingAllowed
|
||||
//nolint:staticcheck // SA1019: prompt.SurveyAskOne is deprecated: use Prompter
|
||||
err = prompt.SurveyAskOne(&survey.Confirm{
|
||||
Message: "Allow forking (of an organization repository)?",
|
||||
Default: r.ForkingAllowed,
|
||||
}, opts.Edits.AllowForking)
|
||||
c, err := opts.Prompter.Confirm(
|
||||
"Allow forking (of an organization repository)?",
|
||||
r.ForkingAllowed)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
opts.Edits.AllowForking = &c
|
||||
}
|
||||
}
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -194,7 +194,53 @@ func Test_editRun_interactive(t *testing.T) {
|
|||
wantsStderr string
|
||||
wantsErr string
|
||||
}{
|
||||
// TODO forking of an org repo
|
||||
{
|
||||
name: "forking of org repo",
|
||||
opts: EditOptions{
|
||||
Repository: ghrepo.NewWithHost("OWNER", "REPO", "github.com"),
|
||||
InteractiveMode: true,
|
||||
},
|
||||
promptStubs: func(pm *prompter.MockPrompter) {
|
||||
el := append(editList, optionAllowForking)
|
||||
pm.RegisterMultiSelect("What do you want to edit?", nil, el,
|
||||
func(_ string, _, opts []string) ([]int, error) {
|
||||
return []int{10}, nil
|
||||
})
|
||||
pm.RegisterConfirm("Allow forking (of an organization repository)?", func(_ string, _ bool) (bool, error) {
|
||||
return true, nil
|
||||
})
|
||||
},
|
||||
httpStubs: func(t *testing.T, reg *httpmock.Registry) {
|
||||
reg.Register(
|
||||
httpmock.GraphQL(`query RepositoryInfo\b`),
|
||||
httpmock.StringResponse(`
|
||||
{
|
||||
"data": {
|
||||
"repository": {
|
||||
"visibility": "public",
|
||||
"description": "description",
|
||||
"homePageUrl": "https://url.com",
|
||||
"defaultBranchRef": {
|
||||
"name": "main"
|
||||
},
|
||||
"isInOrganization": true,
|
||||
"repositoryTopics": {
|
||||
"nodes": [{
|
||||
"topic": {
|
||||
"name": "x"
|
||||
}
|
||||
}]
|
||||
}
|
||||
}
|
||||
}
|
||||
}`))
|
||||
reg.Register(
|
||||
httpmock.REST("PATCH", "repos/OWNER/REPO"),
|
||||
httpmock.RESTPayload(200, `{}`, func(payload map[string]interface{}) {
|
||||
assert.Equal(t, true, payload["allow_forking"])
|
||||
}))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "the rest",
|
||||
opts: EditOptions{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue