mirror of
				https://github.com/go-gitea/gitea.git
				synced 2025-10-31 19:06:18 +01:00 
			
		
		
		
	Add tests for webhook and fix some webhook bugs (#33396)
This PR created a mock webhook server in the tests and added integration tests for generic webhooks. It also fixes bugs in package webhooks and pull request comment webhooks.
This commit is contained in:
		| @@ -471,6 +471,15 @@ func TestAPIMirrorSyncNonMirrorRepo(t *testing.T) { | ||||
| 	assert.Equal(t, "Repository is not a mirror", errRespJSON["message"]) | ||||
| } | ||||
|  | ||||
| func testAPIOrgCreateRepo(t *testing.T, session *TestSession, orgName, repoName string, status int) { | ||||
| 	token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteOrganization, auth_model.AccessTokenScopeWriteRepository) | ||||
|  | ||||
| 	req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/org/%s/repos", orgName), &api.CreateRepoOption{ | ||||
| 		Name: repoName, | ||||
| 	}).AddTokenAuth(token) | ||||
| 	MakeRequest(t, req, status) | ||||
| } | ||||
|  | ||||
| func TestAPIOrgRepoCreate(t *testing.T) { | ||||
| 	testCases := []struct { | ||||
| 		ctxUserID         int64 | ||||
| @@ -488,11 +497,7 @@ func TestAPIOrgRepoCreate(t *testing.T) { | ||||
| 	for _, testCase := range testCases { | ||||
| 		user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: testCase.ctxUserID}) | ||||
| 		session := loginUser(t, user.Name) | ||||
| 		token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteOrganization, auth_model.AccessTokenScopeWriteRepository) | ||||
| 		req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/org/%s/repos", testCase.orgName), &api.CreateRepoOption{ | ||||
| 			Name: testCase.repoName, | ||||
| 		}).AddTokenAuth(token) | ||||
| 		MakeRequest(t, req, testCase.expectedStatus) | ||||
| 		testAPIOrgCreateRepo(t, session, testCase.orgName, testCase.repoName, testCase.expectedStatus) | ||||
| 	} | ||||
| } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user