Skip to content

Commit ec526bf

Browse files
committed
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.
1 parent e373ad6 commit ec526bf

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

pkg/cmd/issue/edit/edit_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ func Test_editRun(t *testing.T) {
347347
{
348348
name: "non-interactive",
349349
input: &EditOptions{
350+
Detector: &fd.EnabledDetectorMock{},
350351
IssueNumbers: []int{123},
351352
Interactive: false,
352353
Editable: prShared.Editable{
@@ -403,6 +404,7 @@ func Test_editRun(t *testing.T) {
403404
{
404405
name: "non-interactive multiple issues",
405406
input: &EditOptions{
407+
Detector: &fd.EnabledDetectorMock{},
406408
IssueNumbers: []int{456, 123},
407409
Interactive: false,
408410
Editable: prShared.Editable{
@@ -457,6 +459,7 @@ func Test_editRun(t *testing.T) {
457459
{
458460
name: "non-interactive multiple issues with fetch failures",
459461
input: &EditOptions{
462+
Detector: &fd.EnabledDetectorMock{},
460463
IssueNumbers: []int{123, 9999},
461464
Interactive: false,
462465
Editable: prShared.Editable{
@@ -504,6 +507,7 @@ func Test_editRun(t *testing.T) {
504507
{
505508
name: "non-interactive multiple issues with update failures",
506509
input: &EditOptions{
510+
Detector: &fd.EnabledDetectorMock{},
507511
IssueNumbers: []int{123, 456},
508512
Interactive: false,
509513
Editable: prShared.Editable{
@@ -584,6 +588,7 @@ func Test_editRun(t *testing.T) {
584588
{
585589
name: "interactive",
586590
input: &EditOptions{
591+
Detector: &fd.EnabledDetectorMock{},
587592
IssueNumbers: []int{123},
588593
Interactive: true,
589594
FieldsToEditSurvey: func(p prShared.EditPrompter, eo *prShared.Editable) error {
@@ -623,6 +628,7 @@ func Test_editRun(t *testing.T) {
623628
{
624629
name: "interactive prompts with actor assignee display names when actors available",
625630
input: &EditOptions{
631+
Detector: &fd.EnabledDetectorMock{},
626632
IssueNumbers: []int{123},
627633
Interactive: true,
628634
FieldsToEditSurvey: func(p prShared.EditPrompter, eo *prShared.Editable) error {

pkg/cmd/pr/edit/edit_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010

1111
"github.com/cli/cli/v2/api"
1212
fd "github.com/cli/cli/v2/internal/featuredetection"
13+
"github.com/cli/cli/v2/internal/gh"
1314
"github.com/cli/cli/v2/internal/ghrepo"
1415
shared "github.com/cli/cli/v2/pkg/cmd/pr/shared"
1516
"github.com/cli/cli/v2/pkg/cmdutil"
@@ -1102,8 +1103,8 @@ func mockProjectV2ItemUpdate(reg *httpmock.Registry) {
11021103

11031104
type testFetcher struct{}
11041105

1105-
func (f testFetcher) EditableOptionsFetch(client *api.Client, repo ghrepo.Interface, opts *shared.Editable) error {
1106-
return shared.FetchOptions(client, repo, opts)
1106+
func (f testFetcher) EditableOptionsFetch(client *api.Client, repo ghrepo.Interface, opts *shared.Editable, projectsV1Support gh.ProjectsV1Support) error {
1107+
return shared.FetchOptions(client, repo, opts, projectsV1Support)
11071108
}
11081109

11091110
type testSurveyor struct {

0 commit comments

Comments
 (0)