@@ -141,7 +141,7 @@ jobs:
141141 t .Run ("test " + tc .treePath , func (t * testing.T ) {
142142 // create the workflow file
143143 opts := getWorkflowCreateFileOptions (user2 , apiRepo .DefaultBranch , "create " + tc .treePath , tc .fileContent )
144- fileResp := createWorkflowFile (t , token , user2 .Name , apiRepo .Name , tc . treePath , apiRepo . GroupID , opts )
144+ fileResp := createWorkflowFile (t , token , user2 .Name , apiRepo .Name , apiRepo . GroupID , tc . treePath , opts )
145145
146146 // fetch and execute task
147147 for i := 0 ; i < len (tc .outcomes ); i ++ {
@@ -153,7 +153,11 @@ jobs:
153153 }
154154
155155 // check result
156- req := NewRequest (t , "GET" , fmt .Sprintf ("/api/v1/repos/%s/%d/%s/actions/tasks" , user2 .Name , apiRepo .GroupID , apiRepo .Name )).
156+ var groupSegment string
157+ if apiRepo .GroupID > 0 {
158+ groupSegment = fmt .Sprintf ("%d/" , apiRepo .GroupID )
159+ }
160+ req := NewRequest (t , "GET" , fmt .Sprintf ("/api/v1/repos/%s/%s%s/actions/tasks" , user2 .Name , groupSegment , apiRepo .Name )).
157161 AddTokenAuth (token )
158162 resp := MakeRequest (t , req , http .StatusOK )
159163 var actionTaskRespAfter api.ActionTaskResponse
@@ -323,7 +327,7 @@ jobs:
323327 for _ , tc := range testCases {
324328 t .Run ("test " + tc .treePath , func (t * testing.T ) {
325329 opts := getWorkflowCreateFileOptions (user2 , apiRepo .DefaultBranch , "create " + tc .treePath , tc .fileContent )
326- createWorkflowFile (t , token , user2 .Name , apiRepo .Name , tc . treePath , apiRepo . GroupID , opts )
330+ createWorkflowFile (t , token , user2 .Name , apiRepo .Name , apiRepo . GroupID , tc . treePath , opts )
327331
328332 for i := 0 ; i < len (tc .outcomes ); i ++ {
329333 task := runner .fetchTask (t )
@@ -373,7 +377,7 @@ jobs:
373377 - run: echo 'test the pull'
374378`
375379 opts := getWorkflowCreateFileOptions (user2 , baseRepo .DefaultBranch , "create " + wfTreePath , wfFileContent )
376- createWorkflowFile (t , user2Token , baseRepo .OwnerName , baseRepo .Name , wfTreePath , baseRepo .GroupID , opts )
380+ createWorkflowFile (t , user2Token , baseRepo .OwnerName , baseRepo .Name , baseRepo .GroupID , wfTreePath , opts )
377381 // user2 creates a pull request
378382 doAPICreateFile (user2APICtx , "user2-patch.txt" , & api.CreateFileOptions {
379383 FileOptions : api.FileOptions {
@@ -465,7 +469,7 @@ jobs:
465469 - run: echo 'test the pull'
466470`
467471 opts := getWorkflowCreateFileOptions (user2 , baseRepo .DefaultBranch , "create " + wfTreePath , wfFileContent )
468- createWorkflowFile (t , user2Token , baseRepo .OwnerName , baseRepo .Name , wfTreePath , baseRepo .GroupID , opts )
472+ createWorkflowFile (t , user2Token , baseRepo .OwnerName , baseRepo .Name , baseRepo .GroupID , wfTreePath , opts )
469473 // user2 creates a pull request
470474 doAPICreateFile (user2APICtx , "user2-patch.txt" , & api.CreateFileOptions {
471475 FileOptions : api.FileOptions {
@@ -617,8 +621,12 @@ func getWorkflowCreateFileOptions(u *user_model.User, branch, msg, content strin
617621 }
618622}
619623
620- func createWorkflowFile (t * testing.T , authToken , ownerName , repoName , treePath string , groupID int64 , opts * api.CreateFileOptions ) * api.FileResponse {
621- req := NewRequestWithJSON (t , "POST" , fmt .Sprintf ("/api/v1/repos/%s/%d/%s/contents/%s" , ownerName , groupID , repoName , treePath ), opts ).
624+ func createWorkflowFile (t * testing.T , authToken , ownerName , repoName string , groupID int64 , treePath string , opts * api.CreateFileOptions ) * api.FileResponse {
625+ var groupSegment string
626+ if groupID > 0 {
627+ groupSegment = fmt .Sprintf ("%d/" , groupID )
628+ }
629+ req := NewRequestWithJSON (t , "POST" , fmt .Sprintf ("/api/v1/repos/%s/%s%s/contents/%s" , ownerName , groupSegment , repoName , treePath ), opts ).
622630 AddTokenAuth (authToken )
623631 resp := MakeRequest (t , req , http .StatusCreated )
624632 var fileResponse api.FileResponse
0 commit comments