You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
42 lines
1.2 KiB
42 lines
1.2 KiB
8 years ago
|
// Copyright 2017 The Gitea Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a MIT-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
2 years ago
|
package integration
|
||
8 years ago
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"net/http"
|
||
|
"testing"
|
||
|
|
||
3 years ago
|
repo_model "code.gitea.io/gitea/models/repo"
|
||
3 years ago
|
"code.gitea.io/gitea/models/unittest"
|
||
3 years ago
|
user_model "code.gitea.io/gitea/models/user"
|
||
2 years ago
|
"code.gitea.io/gitea/tests"
|
||
8 years ago
|
)
|
||
|
|
||
|
func TestChangeDefaultBranch(t *testing.T) {
|
||
2 years ago
|
defer tests.PrepareTestEnv(t)()
|
||
2 years ago
|
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
|
||
|
owner := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: repo.OwnerID})
|
||
8 years ago
|
|
||
7 years ago
|
session := loginUser(t, owner.Name)
|
||
8 years ago
|
branchesURL := fmt.Sprintf("/%s/%s/settings/branches", owner.Name, repo.Name)
|
||
|
|
||
7 years ago
|
csrf := GetCSRF(t, session, branchesURL)
|
||
|
req := NewRequestWithValues(t, "POST", branchesURL, map[string]string{
|
||
|
"_csrf": csrf,
|
||
7 years ago
|
"action": "default_branch",
|
||
|
"branch": "DefaultBranch",
|
||
|
})
|
||
3 years ago
|
session.MakeRequest(t, req, http.StatusSeeOther)
|
||
7 years ago
|
|
||
7 years ago
|
csrf = GetCSRF(t, session, branchesURL)
|
||
7 years ago
|
req = NewRequestWithValues(t, "POST", branchesURL, map[string]string{
|
||
7 years ago
|
"_csrf": csrf,
|
||
7 years ago
|
"action": "default_branch",
|
||
|
"branch": "does_not_exist",
|
||
|
})
|
||
7 years ago
|
session.MakeRequest(t, req, http.StatusNotFound)
|
||
8 years ago
|
}
|