@@ -1302,24 +1302,33 @@ func TestCommitAndPush(t *testing.T) {
13021302 wantErr bool
13031303 expectedErrMsg string
13041304 check func (t * testing.T , repo gitrepo.Repository )
1305+ wantPRBodyFile bool
13051306 }{
13061307 {
13071308 name : "Push flag and Commit flag are not specified" ,
13081309 setupMockRepo : func (t * testing.T ) gitrepo.Repository {
13091310 return & MockRepository {
13101311 Dir : t .TempDir (),
1312+ RemotesValue : []* gitrepo.Remote {
1313+ {
1314+ Name : "origin" ,
1315+ URLs : []string {"https://github.com/googleapis/librarian.git" },
1316+ },
1317+ },
13111318 }
13121319 },
13131320 setupMockClient : func (t * testing.T ) GitHubClient {
13141321 return nil
13151322 },
1316- prType : "generate" ,
1323+ state : & config.LibrarianState {},
1324+ prType : "release" ,
13171325 check : func (t * testing.T , repo gitrepo.Repository ) {
13181326 mockRepo := repo .(* MockRepository )
13191327 if mockRepo .PushCalls != 0 {
13201328 t .Errorf ("Push was called %d times, expected 0" , mockRepo .PushCalls )
13211329 }
13221330 },
1331+ wantPRBodyFile : true ,
13231332 },
13241333 {
13251334 name : "create a commit" ,
@@ -1341,14 +1350,16 @@ func TestCommitAndPush(t *testing.T) {
13411350 createdPR : & github.PullRequestMetadata {Number : 123 , Repo : & github.Repository {Owner : "test-owner" , Name : "test-repo" }},
13421351 }
13431352 },
1344- prType : "generate" ,
1353+ state : & config.LibrarianState {},
1354+ prType : "release" ,
13451355 commit : true ,
13461356 check : func (t * testing.T , repo gitrepo.Repository ) {
13471357 mockRepo := repo .(* MockRepository )
13481358 if mockRepo .PushCalls != 0 {
13491359 t .Errorf ("Push was called %d times, expected 0" , mockRepo .PushCalls )
13501360 }
13511361 },
1362+ wantPRBodyFile : true ,
13521363 },
13531364 {
13541365 name : "create a generate pull request" ,
@@ -1649,6 +1660,11 @@ func TestCommitAndPush(t *testing.T) {
16491660 if test .check != nil {
16501661 test .check (t , repo )
16511662 }
1663+
1664+ gotPRBodyFile := gotPRBodyFile (t , commitInfo .workRoot )
1665+ if test .wantPRBodyFile != gotPRBodyFile {
1666+ t .Errorf ("commitAndPush() wantPRBodyFile = %t, gotPRBodyFile = %t" , test .wantPRBodyFile , gotPRBodyFile )
1667+ }
16521668 })
16531669 }
16541670}
@@ -1730,19 +1746,23 @@ func TestWritePRBody(t *testing.T) {
17301746 } {
17311747 t .Run (test .name , func (t * testing.T ) {
17321748 writePRBody (test .info )
1733- possibleFilePath := filepath .Join (test .info .workRoot , prBodyFile )
1734- _ , err := os .Stat (possibleFilePath )
1735- if err != nil && ! os .IsNotExist (err ) {
1736- t .Fatalf ("error other than IsNotExist finding status of %s" , possibleFilePath )
1737- }
1738- gotFile := err == nil
1749+ gotFile := gotPRBodyFile (t , test .info .workRoot )
17391750 if test .wantFile != gotFile {
17401751 t .Errorf ("writePRBody() wantFile = %t, gotFile = %t" , test .wantFile , gotFile )
17411752 }
17421753 })
17431754 }
17441755}
17451756
1757+ func gotPRBodyFile (t * testing.T , workRoot string ) bool {
1758+ possibleFilePath := filepath .Join (workRoot , prBodyFile )
1759+ _ , err := os .Stat (possibleFilePath )
1760+ if err != nil && ! os .IsNotExist (err ) {
1761+ t .Fatalf ("error other than IsNotExist finding status of %s" , possibleFilePath )
1762+ }
1763+ return err == nil
1764+ }
1765+
17461766func TestAddLabelsToPullRequest (t * testing.T ) {
17471767 for _ , test := range []struct {
17481768 name string
0 commit comments