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.

repo_migrate_test.go 1.1KB

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