Inject Detector mock in edit command tests
Added Detector field with EnabledDetectorMock to EditOptions in issue and PR edit command tests to ensure feature detection logic is exercised during test runs. Also updated EditableOptionsFetch signature in pr/edit/edit_test.go to include projectsV1Support parameter for compatibility with shared.FetchOptions.
This commit is contained in:
parent
e373ad6c9f
commit
ec526bf72b
2 changed files with 9 additions and 2 deletions
|
|
@ -347,6 +347,7 @@ func Test_editRun(t *testing.T) {
|
|||
{
|
||||
name: "non-interactive",
|
||||
input: &EditOptions{
|
||||
Detector: &fd.EnabledDetectorMock{},
|
||||
IssueNumbers: []int{123},
|
||||
Interactive: false,
|
||||
Editable: prShared.Editable{
|
||||
|
|
@ -403,6 +404,7 @@ func Test_editRun(t *testing.T) {
|
|||
{
|
||||
name: "non-interactive multiple issues",
|
||||
input: &EditOptions{
|
||||
Detector: &fd.EnabledDetectorMock{},
|
||||
IssueNumbers: []int{456, 123},
|
||||
Interactive: false,
|
||||
Editable: prShared.Editable{
|
||||
|
|
@ -457,6 +459,7 @@ func Test_editRun(t *testing.T) {
|
|||
{
|
||||
name: "non-interactive multiple issues with fetch failures",
|
||||
input: &EditOptions{
|
||||
Detector: &fd.EnabledDetectorMock{},
|
||||
IssueNumbers: []int{123, 9999},
|
||||
Interactive: false,
|
||||
Editable: prShared.Editable{
|
||||
|
|
@ -504,6 +507,7 @@ func Test_editRun(t *testing.T) {
|
|||
{
|
||||
name: "non-interactive multiple issues with update failures",
|
||||
input: &EditOptions{
|
||||
Detector: &fd.EnabledDetectorMock{},
|
||||
IssueNumbers: []int{123, 456},
|
||||
Interactive: false,
|
||||
Editable: prShared.Editable{
|
||||
|
|
@ -584,6 +588,7 @@ func Test_editRun(t *testing.T) {
|
|||
{
|
||||
name: "interactive",
|
||||
input: &EditOptions{
|
||||
Detector: &fd.EnabledDetectorMock{},
|
||||
IssueNumbers: []int{123},
|
||||
Interactive: true,
|
||||
FieldsToEditSurvey: func(p prShared.EditPrompter, eo *prShared.Editable) error {
|
||||
|
|
@ -623,6 +628,7 @@ func Test_editRun(t *testing.T) {
|
|||
{
|
||||
name: "interactive prompts with actor assignee display names when actors available",
|
||||
input: &EditOptions{
|
||||
Detector: &fd.EnabledDetectorMock{},
|
||||
IssueNumbers: []int{123},
|
||||
Interactive: true,
|
||||
FieldsToEditSurvey: func(p prShared.EditPrompter, eo *prShared.Editable) error {
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@ import (
|
|||
|
||||
"github.com/cli/cli/v2/api"
|
||||
fd "github.com/cli/cli/v2/internal/featuredetection"
|
||||
"github.com/cli/cli/v2/internal/gh"
|
||||
"github.com/cli/cli/v2/internal/ghrepo"
|
||||
shared "github.com/cli/cli/v2/pkg/cmd/pr/shared"
|
||||
"github.com/cli/cli/v2/pkg/cmdutil"
|
||||
|
|
@ -1102,8 +1103,8 @@ func mockProjectV2ItemUpdate(reg *httpmock.Registry) {
|
|||
|
||||
type testFetcher struct{}
|
||||
|
||||
func (f testFetcher) EditableOptionsFetch(client *api.Client, repo ghrepo.Interface, opts *shared.Editable) error {
|
||||
return shared.FetchOptions(client, repo, opts)
|
||||
func (f testFetcher) EditableOptionsFetch(client *api.Client, repo ghrepo.Interface, opts *shared.Editable, projectsV1Support gh.ProjectsV1Support) error {
|
||||
return shared.FetchOptions(client, repo, opts, projectsV1Support)
|
||||
}
|
||||
|
||||
type testSurveyor struct {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue