mirror of
				https://codeberg.org/forgejo/forgejo.git
				synced 2025-10-28 13:01:04 +00:00 
			
		
		
		
	fix(api): issue state change is not idempotent
The PATCH if issue & pull request switched to use the service functions instead. However, the service function changing the state is not idempotent. Instead of doing nothing which changing from open to open or close to close, it will fail with an error like: Issue [2472] 0 was already closed Regression of:6a4bc0289dFixes: https://codeberg.org/forgejo/forgejo/issues/4686 (cherry picked from commite9e3b8c0f3)
This commit is contained in:
		
					parent
					
						
							
								887a914a7d
							
						
					
				
			
			
				commit
				
					
						533623b659
					
				
			
		
					 4 changed files with 44 additions and 12 deletions
				
			
		|  | @ -215,6 +215,21 @@ func TestAPIEditIssue(t *testing.T) { | |||
| 	assert.Equal(t, int64(0), int64(issueAfter.DeadlineUnix)) | ||||
| 	assert.Equal(t, body, issueAfter.Content) | ||||
| 	assert.Equal(t, title, issueAfter.Title) | ||||
| 
 | ||||
| 	// verify the idempotency of state, milestone, body and title changes | ||||
| 	req = NewRequestWithJSON(t, "PATCH", urlStr, api.EditIssueOption{ | ||||
| 		State:     &issueState, | ||||
| 		Milestone: &milestone, | ||||
| 		Body:      &body, | ||||
| 		Title:     title, | ||||
| 	}).AddTokenAuth(token) | ||||
| 	resp = MakeRequest(t, req, http.StatusCreated) | ||||
| 	var apiIssueIdempotent api.Issue | ||||
| 	DecodeJSON(t, resp, &apiIssueIdempotent) | ||||
| 	assert.Equal(t, apiIssue.State, apiIssueIdempotent.State) | ||||
| 	assert.Equal(t, apiIssue.Milestone.Title, apiIssueIdempotent.Milestone.Title) | ||||
| 	assert.Equal(t, apiIssue.Body, apiIssueIdempotent.Body) | ||||
| 	assert.Equal(t, apiIssue.Title, apiIssueIdempotent.Title) | ||||
| } | ||||
| 
 | ||||
| func TestAPIEditIssueAutoDate(t *testing.T) { | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue