From ec526bf72b9bb70172810d6feff92b2c7f22abf9 Mon Sep 17 00:00:00 2001 From: Kynan Ware <47394200+BagToad@users.noreply.github.com> Date: Tue, 21 Oct 2025 15:55:42 -0600 Subject: [PATCH] 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. --- pkg/cmd/issue/edit/edit_test.go | 6 ++++++ pkg/cmd/pr/edit/edit_test.go | 5 +++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/cmd/issue/edit/edit_test.go b/pkg/cmd/issue/edit/edit_test.go index caf99df58..4261efda7 100644 --- a/pkg/cmd/issue/edit/edit_test.go +++ b/pkg/cmd/issue/edit/edit_test.go @@ -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 { diff --git a/pkg/cmd/pr/edit/edit_test.go b/pkg/cmd/pr/edit/edit_test.go index 47ce30f22..4696d612b 100644 --- a/pkg/cmd/pr/edit/edit_test.go +++ b/pkg/cmd/pr/edit/edit_test.go @@ -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 {