diff --git a/pkg/cmd/issue/create/create_test.go b/pkg/cmd/issue/create/create_test.go index 37dba3407..c89a349a0 100644 --- a/pkg/cmd/issue/create/create_test.go +++ b/pkg/cmd/issue/create/create_test.go @@ -153,7 +153,12 @@ func TestIssueCreate_nonLegacyTemplate(t *testing.T) { }, }) // body - as.StubOneDefault() + as.Stub([]*prompt.QuestionStub{ + { + Name: "Body", + Default: true, + }, + }) // body // confirm as.Stub([]*prompt.QuestionStub{ { diff --git a/pkg/cmd/pr/create/create_test.go b/pkg/cmd/pr/create/create_test.go index 2e7192912..0c9a91c1a 100644 --- a/pkg/cmd/pr/create/create_test.go +++ b/pkg/cmd/pr/create/create_test.go @@ -433,7 +433,12 @@ func TestPRCreate_nonLegacyTemplate(t *testing.T) { Value: 0, }, }) // template - as.StubOneDefault() // body + as.Stub([]*prompt.QuestionStub{ + { + Name: "Body", + Default: true, + }, + }) // body as.Stub([]*prompt.QuestionStub{ { Name: "confirmation", diff --git a/pkg/cmd/pr/shared/survey.go b/pkg/cmd/pr/shared/survey.go index e6df8cf70..03bddb1f8 100644 --- a/pkg/cmd/pr/shared/survey.go +++ b/pkg/cmd/pr/shared/survey.go @@ -170,19 +170,25 @@ func BodySurvey(state *IssueMetadataState, templateContent, editorCommand string state.Body += templateContent } - p := &surveyext.GhEditor{ - BlankAllowed: true, - EditorCommand: editorCommand, - Editor: &survey.Editor{ - Message: "Body", - FileName: "*.md", - Default: state.Body, - HideDefault: true, - AppendDefault: true, + // TODO should just be an AskOne but ran into problems with the stubber + qs := []*survey.Question{ + { + Name: "Body", + Prompt: &surveyext.GhEditor{ + BlankAllowed: true, + EditorCommand: editorCommand, + Editor: &survey.Editor{ + Message: "Body", + FileName: "*.md", + Default: state.Body, + HideDefault: true, + AppendDefault: true, + }, + }, }, } - err := prompt.SurveyAskOne(p, state) + err := prompt.SurveyAsk(qs, state) if err != nil { return err } @@ -191,12 +197,18 @@ func BodySurvey(state *IssueMetadataState, templateContent, editorCommand string } func TitleSurvey(state *IssueMetadataState) error { - p := &survey.Input{ - Message: "Title", - Default: state.Title, + // TODO should just be an AskOne but ran into problems with the stubber + qs := []*survey.Question{ + { + Name: "Title", + Prompt: &survey.Input{ + Message: "Title", + Default: state.Title, + }, + }, } - err := prompt.SurveyAskOne(p, state) + err := prompt.SurveyAsk(qs, state) if err != nil { return err } diff --git a/pkg/prompt/stubber.go b/pkg/prompt/stubber.go index b1470bc0c..a3302c3f9 100644 --- a/pkg/prompt/stubber.go +++ b/pkg/prompt/stubber.go @@ -31,6 +31,7 @@ func InitAskStubber() (*AskStubber, func()) { } stubbedPrompt := as.StubOnes[count] if stubbedPrompt.Default { + // TODO this is failing for basic AskOne invocations with a string result. defaultValue := reflect.ValueOf(p).Elem().FieldByName("Default") _ = core.WriteAnswer(response, "", defaultValue) } else {