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.
47 lines
1.4 KiB
47 lines
1.4 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 (
|
||
4 years ago
|
"fmt"
|
||
8 years ago
|
"net/http"
|
||
7 years ago
|
"net/http/httptest"
|
||
8 years ago
|
"testing"
|
||
|
|
||
4 years ago
|
"code.gitea.io/gitea/modules/structs"
|
||
2 years ago
|
"code.gitea.io/gitea/tests"
|
||
3 years ago
|
|
||
8 years ago
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
7 years ago
|
func testRepoMigrate(t testing.TB, session *TestSession, cloneAddr, repoName string) *httptest.ResponseRecorder {
|
||
4 years ago
|
req := NewRequest(t, "GET", fmt.Sprintf("/repo/migrate?service_type=%d", structs.PlainGitService)) // render plain git migration page
|
||
7 years ago
|
resp := session.MakeRequest(t, req, http.StatusOK)
|
||
8 years ago
|
htmlDoc := NewHTMLParser(t, resp.Body)
|
||
|
|
||
|
link, exists := htmlDoc.doc.Find("form.ui.form").Attr("action")
|
||
|
assert.True(t, exists, "The template has changed")
|
||
|
|
||
|
uid, exists := htmlDoc.doc.Find("#uid").Attr("value")
|
||
|
assert.True(t, exists, "The template has changed")
|
||
|
|
||
|
req = NewRequestWithValues(t, "POST", link, map[string]string{
|
||
|
"_csrf": htmlDoc.GetCSRF(),
|
||
|
"clone_addr": cloneAddr,
|
||
|
"uid": uid,
|
||
|
"repo_name": repoName,
|
||
4 years ago
|
"service": fmt.Sprintf("%d", structs.PlainGitService),
|
||
|
})
|
||
3 years ago
|
resp = session.MakeRequest(t, req, http.StatusSeeOther)
|
||
8 years ago
|
|
||
|
return resp
|
||
|
}
|
||
|
|
||
|
func TestRepoMigrate(t *testing.T) {
|
||
2 years ago
|
defer tests.PrepareTestEnv(t)()
|
||
8 years ago
|
session := loginUser(t, "user2")
|
||
4 years ago
|
testRepoMigrate(t, session, "https://github.com/go-gitea/test_repo.git", "git")
|
||
8 years ago
|
}
|