mirror of
https://github.com/go-gitea/gitea
synced 2025-07-22 18:28:37 +00:00
Add golangci (#6418)
This commit is contained in:
@@ -62,7 +62,7 @@ func branchAction(t *testing.T, button string) (*HTMLDoc, string) {
|
||||
req = NewRequestWithValues(t, "POST", link, map[string]string{
|
||||
"_csrf": getCsrf(t, htmlDoc.doc),
|
||||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
url, err := url.Parse(link)
|
||||
assert.NoError(t, err)
|
||||
|
@@ -34,7 +34,7 @@ func TestCreateFile(t *testing.T) {
|
||||
"content": "Content",
|
||||
"commit_choice": "direct",
|
||||
})
|
||||
resp = session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
})
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
|
||||
"_csrf": csrf,
|
||||
"protected": "on",
|
||||
})
|
||||
resp := session.MakeRequest(t, req, http.StatusFound)
|
||||
session.MakeRequest(t, req, http.StatusFound)
|
||||
// Check if master branch has been locked successfully
|
||||
flashCookie := session.GetCookie("macaron_flash")
|
||||
assert.NotNil(t, flashCookie)
|
||||
@@ -56,7 +56,7 @@ func TestCreateFileOnProtectedBranch(t *testing.T) {
|
||||
|
||||
// Request editor page
|
||||
req = NewRequest(t, "GET", "/user2/repo1/_new/master/")
|
||||
resp = session.MakeRequest(t, req, http.StatusOK)
|
||||
resp := session.MakeRequest(t, req, http.StatusOK)
|
||||
|
||||
doc := NewHTMLParser(t, resp.Body)
|
||||
lastCommit := doc.GetInputValueByName("last_commit")
|
||||
|
@@ -42,7 +42,7 @@ type NilResponseRecorder struct {
|
||||
}
|
||||
|
||||
func (n *NilResponseRecorder) Write(b []byte) (int, error) {
|
||||
n.Length = n.Length + len(b)
|
||||
n.Length += len(b)
|
||||
return len(b), nil
|
||||
}
|
||||
|
||||
@@ -141,8 +141,7 @@ func initIntegrationTest() {
|
||||
if err != nil {
|
||||
log.Fatalf("sql.Open: %v", err)
|
||||
}
|
||||
rows, err := db.Query(fmt.Sprintf("SELECT 1 FROM pg_database WHERE datname = '%s'",
|
||||
models.DbCfg.Name))
|
||||
rows, err := db.Query(fmt.Sprintf("SELECT 1 FROM pg_database WHERE datname = '%s'", models.DbCfg.Name))
|
||||
if err != nil {
|
||||
log.Fatalf("db.Query: %v", err)
|
||||
}
|
||||
@@ -210,7 +209,7 @@ func (s *TestSession) MakeRequest(t testing.TB, req *http.Request, expectedStatu
|
||||
resp := MakeRequest(t, req, expectedStatus)
|
||||
|
||||
ch := http.Header{}
|
||||
ch.Add("Cookie", strings.Join(resp.HeaderMap["Set-Cookie"], ";"))
|
||||
ch.Add("Cookie", strings.Join(resp.Header()["Set-Cookie"], ";"))
|
||||
cr := http.Request{Header: ch}
|
||||
s.jar.SetCookies(baseURL, cr.Cookies())
|
||||
|
||||
@@ -226,7 +225,7 @@ func (s *TestSession) MakeRequestNilResponseRecorder(t testing.TB, req *http.Req
|
||||
resp := MakeRequestNilResponseRecorder(t, req, expectedStatus)
|
||||
|
||||
ch := http.Header{}
|
||||
ch.Add("Cookie", strings.Join(resp.HeaderMap["Set-Cookie"], ";"))
|
||||
ch.Add("Cookie", strings.Join(resp.Header()["Set-Cookie"], ";"))
|
||||
cr := http.Request{Header: ch}
|
||||
s.jar.SetCookies(baseURL, cr.Cookies())
|
||||
|
||||
@@ -266,7 +265,7 @@ func loginUserWithPassword(t testing.TB, userName, password string) *TestSession
|
||||
resp = MakeRequest(t, req, http.StatusFound)
|
||||
|
||||
ch := http.Header{}
|
||||
ch.Add("Cookie", strings.Join(resp.HeaderMap["Set-Cookie"], ";"))
|
||||
ch.Add("Cookie", strings.Join(resp.Header()["Set-Cookie"], ";"))
|
||||
cr := http.Request{Header: ch}
|
||||
|
||||
session := emptyTestSession(t)
|
||||
|
@@ -45,7 +45,7 @@ func storeObjectInRepo(t *testing.T, repositoryID int64, content *[]byte) string
|
||||
lfsMetaObject = &models.LFSMetaObject{Oid: oid, Size: int64(len(*content)), RepositoryID: repositoryID}
|
||||
}
|
||||
|
||||
lfsID = lfsID + 1
|
||||
lfsID++
|
||||
lfsMetaObject, err = models.NewLFSMetaObject(lfsMetaObject)
|
||||
assert.NoError(t, err)
|
||||
contentStore := &lfs.ContentStore{BasePath: setting.LFS.ContentPath}
|
||||
|
@@ -57,21 +57,6 @@ func initMigrationTest(t *testing.T) {
|
||||
setting.NewLogServices(true)
|
||||
}
|
||||
|
||||
func getDialect() string {
|
||||
dialect := "sqlite"
|
||||
switch {
|
||||
case setting.UseSQLite3:
|
||||
dialect = "sqlite"
|
||||
case setting.UseMySQL:
|
||||
dialect = "mysql"
|
||||
case setting.UsePostgreSQL:
|
||||
dialect = "pgsql"
|
||||
case setting.UseMSSQL:
|
||||
dialect = "mssql"
|
||||
}
|
||||
return dialect
|
||||
}
|
||||
|
||||
func availableVersions() ([]string, error) {
|
||||
migrationsDir, err := os.Open("integrations/migration-test")
|
||||
if err != nil {
|
||||
|
@@ -73,7 +73,7 @@ func PrintCurrentTest(t testing.TB, skip ...int) {
|
||||
_, filename, line, _ := runtime.Caller(actualSkip)
|
||||
|
||||
if log.CanColorStdout {
|
||||
fmt.Fprintf(os.Stdout, "=== %s (%s:%d)\n", log.NewColoredValue(t.Name()), strings.TrimPrefix(filename, prefix), line)
|
||||
fmt.Fprintf(os.Stdout, "=== %s (%s:%d)\n", fmt.Formatter(log.NewColoredValue(t.Name())), strings.TrimPrefix(filename, prefix), line)
|
||||
} else {
|
||||
fmt.Fprintf(os.Stdout, "=== %s (%s:%d)\n", t.Name(), strings.TrimPrefix(filename, prefix), line)
|
||||
}
|
||||
|
Reference in New Issue
Block a user