THIS IS A TEST INSTANCE ONLY! REPOSITORIES CAN BE DELETED AT ANY TIME!

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.

39 lines
1.1KB

  1. // Copyright 2017 The Gitea Authors. All rights reserved.
  2. // Use of this source code is governed by a MIT-style
  3. // license that can be found in the LICENSE file.
  4. package integrations
  5. import (
  6. "fmt"
  7. "net/http"
  8. "testing"
  9. "code.gitea.io/gitea/models"
  10. )
  11. func TestChangeDefaultBranch(t *testing.T) {
  12. prepareTestEnv(t)
  13. repo := models.AssertExistsAndLoadBean(t, &models.Repository{ID: 1}).(*models.Repository)
  14. owner := models.AssertExistsAndLoadBean(t, &models.User{ID: repo.OwnerID}).(*models.User)
  15. session := loginUser(t, owner.Name)
  16. branchesURL := fmt.Sprintf("/%s/%s/settings/branches", owner.Name, repo.Name)
  17. csrf := GetCSRF(t, session, branchesURL)
  18. req := NewRequestWithValues(t, "POST", branchesURL, map[string]string{
  19. "_csrf": csrf,
  20. "action": "default_branch",
  21. "branch": "DefaultBranch",
  22. })
  23. session.MakeRequest(t, req, http.StatusFound)
  24. csrf = GetCSRF(t, session, branchesURL)
  25. req = NewRequestWithValues(t, "POST", branchesURL, map[string]string{
  26. "_csrf": csrf,
  27. "action": "default_branch",
  28. "branch": "does_not_exist",
  29. })
  30. session.MakeRequest(t, req, http.StatusNotFound)
  31. }