Update template test to reflect inclusion of "default" text

Also, avoid excessive amounts of newlines separating the two
This commit is contained in:
Daniel Leong 2020-09-08 20:25:52 -04:00
parent 41543b564d
commit c7e702203b
2 changed files with 4 additions and 1 deletions

View file

@ -316,7 +316,7 @@ func TestPRCreate_nonLegacyTemplate(t *testing.T) {
eq(t, reqBody.Variables.Input.RepositoryID, "REPOID")
eq(t, reqBody.Variables.Input.Title, "my title")
eq(t, reqBody.Variables.Input.Body, "Fixes a bug and Closes an issue")
eq(t, reqBody.Variables.Input.Body, "- commit 1\n- commit 0\n\nFixes a bug and Closes an issue")
eq(t, reqBody.Variables.Input.BaseRefName, "master")
eq(t, reqBody.Variables.Input.HeadRefName, "feature")

View file

@ -2,6 +2,7 @@ package shared
import (
"fmt"
"strings"
"github.com/AlecAivazis/survey/v2"
"github.com/cli/cli/api"
@ -169,6 +170,8 @@ func TitleBodySurvey(io *iostreams.IOStreams, editorCommand string, issueState *
if templateContents != "" {
if issueState.Body != "" {
// prevent excessive newlines between default body and template
issueState.Body = strings.TrimRight(issueState.Body, "\n")
issueState.Body += "\n\n"
}
issueState.Body += templateContents