mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-22 12:54:53 -05:00
[TESTS] add TestAPIForkDifferentName
Refs: https://codeberg.org/forgejo/forgejo/pulls/1719 (cherry picked from commited34138915
) (cherry picked from commit166d769a6e
) (cherry picked from commit8da818646c
)
This commit is contained in:
parent
aff135418d
commit
95c9d6ede4
1 changed files with 23 additions and 0 deletions
|
@ -206,6 +206,29 @@ func TestAPIEditPull(t *testing.T) {
|
|||
MakeRequest(t, req, http.StatusNotFound)
|
||||
}
|
||||
|
||||
func TestAPIForkDifferentName(t *testing.T) {
|
||||
defer tests.PrepareTestEnv(t)()
|
||||
|
||||
// Step 1: get a repo and a user that can fork this repo
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||||
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
|
||||
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 5})
|
||||
|
||||
session := loginUser(t, user.Name)
|
||||
token := getTokenForLoggedInUser(t, session, auth_model.AccessTokenScopeWriteRepository, auth_model.AccessTokenScopeWriteUser)
|
||||
|
||||
// Step 2: fork this repo with another name
|
||||
forkName := "myfork"
|
||||
req := NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/forks?token="+token, owner.Name, repo.Name),
|
||||
&api.CreateForkOption{Name: &forkName})
|
||||
MakeRequest(t, req, http.StatusAccepted)
|
||||
|
||||
// Step 3: make a PR onto the original repo, it should succeed
|
||||
req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/api/v1/repos/%s/%s/pulls?state=all&token="+token, owner.Name, repo.Name),
|
||||
&api.CreatePullRequestOption{Head: user.Name + ":master", Base: "master", Title: "hi"})
|
||||
MakeRequest(t, req, http.StatusCreated)
|
||||
}
|
||||
|
||||
func doAPIGetPullFiles(ctx APITestContext, pr *api.PullRequest, callback func(*testing.T, []*api.ChangedFile)) func(*testing.T) {
|
||||
return func(t *testing.T) {
|
||||
url := fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/files?token=%s", ctx.Username, ctx.Reponame, pr.Index, ctx.Token)
|
||||
|
|
Loading…
Reference in a new issue