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.

44 lines
1.4 KiB

  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. "net/http/httptest"
  9. "testing"
  10. "code.gitea.io/gitea/modules/structs"
  11. "github.com/stretchr/testify/assert"
  12. )
  13. func testRepoMigrate(t testing.TB, session *TestSession, cloneAddr, repoName string) *httptest.ResponseRecorder {
  14. req := NewRequest(t, "GET", fmt.Sprintf("/repo/migrate?service_type=%d", structs.PlainGitService)) // render plain git migration page
  15. resp := session.MakeRequest(t, req, http.StatusOK)
  16. htmlDoc := NewHTMLParser(t, resp.Body)
  17. link, exists := htmlDoc.doc.Find("form.ui.form").Attr("action")
  18. assert.True(t, exists, "The template has changed")
  19. uid, exists := htmlDoc.doc.Find("#uid").Attr("value")
  20. assert.True(t, exists, "The template has changed")
  21. req = NewRequestWithValues(t, "POST", link, map[string]string{
  22. "_csrf": htmlDoc.GetCSRF(),
  23. "clone_addr": cloneAddr,
  24. "uid": uid,
  25. "repo_name": repoName,
  26. "service": fmt.Sprintf("%d", structs.PlainGitService),
  27. })
  28. resp = session.MakeRequest(t, req, http.StatusFound)
  29. return resp
  30. }
  31. func TestRepoMigrate(t *testing.T) {
  32. defer prepareTestEnv(t)()
  33. session := loginUser(t, "user2")
  34. testRepoMigrate(t, session, "https://github.com/go-gitea/test_repo.git", "git")
  35. }