Update module github.com/golangci/golangci-lint/cmd/golangci-lint to v2 (forgejo) (#7367)
Co-authored-by: Renovate Bot <forgejo-renovate-action@forgejo.org> Co-committed-by: Renovate Bot <forgejo-renovate-action@forgejo.org>
This commit is contained in:
parent
51ff4970ec
commit
fed2d81c44
427 changed files with 2043 additions and 2046 deletions
|
@ -19,7 +19,7 @@ func TestCreateAuthorizationToken(t *testing.T) {
|
|||
var taskID int64 = 23
|
||||
token, err := CreateAuthorizationToken(taskID, 1, 2)
|
||||
require.NoError(t, err)
|
||||
assert.NotEqual(t, "", token)
|
||||
assert.NotEmpty(t, token)
|
||||
claims := jwt.MapClaims{}
|
||||
_, err = jwt.ParseWithClaims(token, claims, func(t *jwt.Token) (any, error) {
|
||||
return setting.GetGeneralTokenSigningSecret(), nil
|
||||
|
@ -45,7 +45,7 @@ func TestParseAuthorizationToken(t *testing.T) {
|
|||
var taskID int64 = 23
|
||||
token, err := CreateAuthorizationToken(taskID, 1, 2)
|
||||
require.NoError(t, err)
|
||||
assert.NotEqual(t, "", token)
|
||||
assert.NotEmpty(t, token)
|
||||
headers := http.Header{}
|
||||
headers.Set("Authorization", "Bearer "+token)
|
||||
rTaskID, err := ParseAuthorizationToken(&http.Request{
|
||||
|
|
|
@ -24,7 +24,7 @@ func TestCleanup(t *testing.T) {
|
|||
require.NoError(t, CleanupLogs(db.DefaultContext))
|
||||
|
||||
task := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionTask{ID: 1001})
|
||||
assert.EqualValues(t, "does-not-exist", task.LogFilename)
|
||||
assert.Equal(t, "does-not-exist", task.LogFilename)
|
||||
assert.True(t, task.LogExpired)
|
||||
assert.Nil(t, task.LogIndexes)
|
||||
})
|
||||
|
|
|
@ -43,6 +43,6 @@ func TestUploadAttachment(t *testing.T) {
|
|||
|
||||
attachment, err := repo_model.GetAttachmentByUUID(db.DefaultContext, attach.UUID)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, user.ID, attachment.UploaderID)
|
||||
assert.Equal(t, user.ID, attachment.UploaderID)
|
||||
assert.Equal(t, int64(0), attachment.DownloadCount)
|
||||
}
|
||||
|
|
|
@ -38,10 +38,10 @@ func TestReverseProxyAuth(t *testing.T) {
|
|||
|
||||
require.EqualValues(t, 1, user_model.CountUsers(db.DefaultContext, nil))
|
||||
unittest.AssertExistsAndLoadBean(t, &user_model.User{Email: "edgar@example.org", Name: "Edgar", LowerName: "edgar", FullName: "Edgar Allan Poe", IsAdmin: true})
|
||||
require.EqualValues(t, "edgar@example.org", user.Email)
|
||||
require.EqualValues(t, "Edgar", user.Name)
|
||||
require.EqualValues(t, "edgar", user.LowerName)
|
||||
require.EqualValues(t, "Edgar Allan Poe", user.FullName)
|
||||
require.Equal(t, "edgar@example.org", user.Email)
|
||||
require.Equal(t, "Edgar", user.Name)
|
||||
require.Equal(t, "edgar", user.LowerName)
|
||||
require.Equal(t, "Edgar Allan Poe", user.FullName)
|
||||
require.True(t, user.IsAdmin)
|
||||
})
|
||||
|
||||
|
@ -58,10 +58,10 @@ func TestReverseProxyAuth(t *testing.T) {
|
|||
|
||||
require.EqualValues(t, 2, user_model.CountUsers(db.DefaultContext, nil))
|
||||
unittest.AssertExistsAndLoadBean(t, &user_model.User{Email: "gusted@example.org", Name: "Gusted", LowerName: "gusted", FullName: "❤‿❤"}, "is_admin = false")
|
||||
require.EqualValues(t, "gusted@example.org", user.Email)
|
||||
require.EqualValues(t, "Gusted", user.Name)
|
||||
require.EqualValues(t, "gusted", user.LowerName)
|
||||
require.EqualValues(t, "❤‿❤", user.FullName)
|
||||
require.Equal(t, "gusted@example.org", user.Email)
|
||||
require.Equal(t, "Gusted", user.Name)
|
||||
require.Equal(t, "gusted", user.LowerName)
|
||||
require.Equal(t, "❤‿❤", user.FullName)
|
||||
require.False(t, user.IsAdmin)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ func TestLoadOrCreateAsymmetricKey(t *testing.T) {
|
|||
|
||||
block, _ := pem.Decode(fileContent)
|
||||
assert.NotNil(t, block)
|
||||
assert.EqualValues(t, "PRIVATE KEY", block.Type)
|
||||
assert.Equal(t, "PRIVATE KEY", block.Type)
|
||||
|
||||
parsedKey, err := x509.ParsePKCS8PrivateKey(block.Bytes)
|
||||
require.NoError(t, err)
|
||||
|
@ -44,14 +44,14 @@ func TestLoadOrCreateAsymmetricKey(t *testing.T) {
|
|||
parsedKey := loadKey(t)
|
||||
|
||||
rsaPrivateKey := parsedKey.(*rsa.PrivateKey)
|
||||
assert.EqualValues(t, 2048, rsaPrivateKey.N.BitLen())
|
||||
assert.Equal(t, 2048, rsaPrivateKey.N.BitLen())
|
||||
|
||||
t.Run("Load key with differ specified algorithm", func(t *testing.T) {
|
||||
defer test.MockVariableValue(&setting.OAuth2.JWTSigningAlgorithm, "EdDSA")()
|
||||
|
||||
parsedKey := loadKey(t)
|
||||
rsaPrivateKey := parsedKey.(*rsa.PrivateKey)
|
||||
assert.EqualValues(t, 2048, rsaPrivateKey.N.BitLen())
|
||||
assert.Equal(t, 2048, rsaPrivateKey.N.BitLen())
|
||||
})
|
||||
})
|
||||
|
||||
|
@ -62,7 +62,7 @@ func TestLoadOrCreateAsymmetricKey(t *testing.T) {
|
|||
parsedKey := loadKey(t)
|
||||
|
||||
rsaPrivateKey := parsedKey.(*rsa.PrivateKey)
|
||||
assert.EqualValues(t, 3072, rsaPrivateKey.N.BitLen())
|
||||
assert.Equal(t, 3072, rsaPrivateKey.N.BitLen())
|
||||
})
|
||||
|
||||
t.Run("RSA-4096", func(t *testing.T) {
|
||||
|
@ -72,7 +72,7 @@ func TestLoadOrCreateAsymmetricKey(t *testing.T) {
|
|||
parsedKey := loadKey(t)
|
||||
|
||||
rsaPrivateKey := parsedKey.(*rsa.PrivateKey)
|
||||
assert.EqualValues(t, 4096, rsaPrivateKey.N.BitLen())
|
||||
assert.Equal(t, 4096, rsaPrivateKey.N.BitLen())
|
||||
})
|
||||
|
||||
t.Run("ECDSA-256", func(t *testing.T) {
|
||||
|
@ -82,7 +82,7 @@ func TestLoadOrCreateAsymmetricKey(t *testing.T) {
|
|||
parsedKey := loadKey(t)
|
||||
|
||||
ecdsaPrivateKey := parsedKey.(*ecdsa.PrivateKey)
|
||||
assert.EqualValues(t, 256, ecdsaPrivateKey.Params().BitSize)
|
||||
assert.Equal(t, 256, ecdsaPrivateKey.Params().BitSize)
|
||||
})
|
||||
|
||||
t.Run("ECDSA-384", func(t *testing.T) {
|
||||
|
@ -92,7 +92,7 @@ func TestLoadOrCreateAsymmetricKey(t *testing.T) {
|
|||
parsedKey := loadKey(t)
|
||||
|
||||
ecdsaPrivateKey := parsedKey.(*ecdsa.PrivateKey)
|
||||
assert.EqualValues(t, 384, ecdsaPrivateKey.Params().BitSize)
|
||||
assert.Equal(t, 384, ecdsaPrivateKey.Params().BitSize)
|
||||
})
|
||||
|
||||
t.Run("ECDSA-512", func(t *testing.T) {
|
||||
|
@ -102,7 +102,7 @@ func TestLoadOrCreateAsymmetricKey(t *testing.T) {
|
|||
parsedKey := loadKey(t)
|
||||
|
||||
ecdsaPrivateKey := parsedKey.(*ecdsa.PrivateKey)
|
||||
assert.EqualValues(t, 521, ecdsaPrivateKey.Params().BitSize)
|
||||
assert.Equal(t, 521, ecdsaPrivateKey.Params().BitSize)
|
||||
})
|
||||
|
||||
t.Run("EdDSA", func(t *testing.T) {
|
||||
|
|
|
@ -186,7 +186,7 @@ func (ctx *APIContext) Error(status int, title string, obj any) {
|
|||
if status == http.StatusInternalServerError {
|
||||
log.ErrorWithSkip(1, "%s: %s", title, message)
|
||||
|
||||
if setting.IsProd && !(ctx.Doer != nil && ctx.Doer.IsAdmin) {
|
||||
if setting.IsProd && (ctx.Doer == nil || !ctx.Doer.IsAdmin) {
|
||||
message = ""
|
||||
}
|
||||
}
|
||||
|
@ -285,8 +285,8 @@ func APIContexter() func(http.Handler) http.Handler {
|
|||
}
|
||||
defer baseCleanUp()
|
||||
|
||||
ctx.Base.AppendContextValue(apiContextKey, ctx)
|
||||
ctx.Base.AppendContextValueFunc(gitrepo.RepositoryContextKey, func() any { return ctx.Repo.GitRepo })
|
||||
ctx.AppendContextValue(apiContextKey, ctx)
|
||||
ctx.AppendContextValueFunc(gitrepo.RepositoryContextKey, func() any { return ctx.Repo.GitRepo })
|
||||
|
||||
// If request sends files, parse them here otherwise the Query() can't be parsed and the CsrfToken will be invalid.
|
||||
if ctx.Req.Method == "POST" && strings.Contains(ctx.Req.Header.Get("Content-Type"), "multipart/form-data") {
|
||||
|
@ -334,7 +334,7 @@ func (ctx *APIContext) NotFound(objs ...any) {
|
|||
func ReferencesGitRepo(allowEmpty ...bool) func(ctx *APIContext) (cancel context.CancelFunc) {
|
||||
return func(ctx *APIContext) (cancel context.CancelFunc) {
|
||||
// Empty repository does not have reference information.
|
||||
if ctx.Repo.Repository.IsEmpty && !(len(allowEmpty) != 0 && allowEmpty[0]) {
|
||||
if ctx.Repo.Repository.IsEmpty && (len(allowEmpty) == 0 || !allowEmpty[0]) {
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -46,6 +46,6 @@ func TestGenAPILinks(t *testing.T) {
|
|||
|
||||
links := genAPILinks(u, 100, 20, curPage)
|
||||
|
||||
assert.EqualValues(t, links, response)
|
||||
assert.Equal(t, links, response)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -100,7 +100,7 @@ func GetValidateContext(req *http.Request) (ctx *ValidateContext) {
|
|||
|
||||
func NewTemplateContextForWeb(ctx *Context) TemplateContext {
|
||||
tmplCtx := NewTemplateContext(ctx)
|
||||
tmplCtx["Locale"] = ctx.Base.Locale
|
||||
tmplCtx["Locale"] = ctx.Locale
|
||||
tmplCtx["AvatarUtils"] = templates.NewAvatarUtils(ctx)
|
||||
return tmplCtx
|
||||
}
|
||||
|
@ -151,8 +151,8 @@ func Contexter() func(next http.Handler) http.Handler {
|
|||
ctx.PageData = map[string]any{}
|
||||
ctx.Data["PageData"] = ctx.PageData
|
||||
|
||||
ctx.Base.AppendContextValue(WebContextKey, ctx)
|
||||
ctx.Base.AppendContextValueFunc(gitrepo.RepositoryContextKey, func() any { return ctx.Repo.GitRepo })
|
||||
ctx.AppendContextValue(WebContextKey, ctx)
|
||||
ctx.AppendContextValueFunc(gitrepo.RepositoryContextKey, func() any { return ctx.Repo.GitRepo })
|
||||
|
||||
ctx.Csrf = NewCSRFProtector(csrfOpts)
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ func PackageContexter() func(next http.Handler) http.Handler {
|
|||
|
||||
// it is still needed when rendering 500 page in a package handler
|
||||
ctx := NewWebContext(base, renderer, nil)
|
||||
ctx.Base.AppendContextValue(WebContextKey, ctx)
|
||||
ctx.AppendContextValue(WebContextKey, ctx)
|
||||
next.ServeHTTP(ctx.Resp, ctx.Req)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ func PrivateContexter() func(http.Handler) http.Handler {
|
|||
base, baseCleanUp := NewBaseContext(w, req)
|
||||
ctx := &PrivateContext{Base: base}
|
||||
defer baseCleanUp()
|
||||
ctx.Base.AppendContextValue(privateContextKey, ctx)
|
||||
ctx.AppendContextValue(privateContextKey, ctx)
|
||||
|
||||
next.ServeHTTP(ctx.Resp, ctx.Req)
|
||||
})
|
||||
|
|
|
@ -64,7 +64,7 @@ func QuotaRuleAssignmentAPI() func(ctx *APIContext) {
|
|||
|
||||
// ctx.CheckQuota checks whether the user in question is within quota limits (web context)
|
||||
func (ctx *Context) CheckQuota(subject quota_model.LimitSubject, userID int64, username string) bool {
|
||||
ok, err := checkQuota(ctx.Base.originCtx, subject, userID, username, func(userID int64, username string) {
|
||||
ok, err := checkQuota(ctx.originCtx, subject, userID, username, func(userID int64, username string) {
|
||||
showHTML := false
|
||||
for _, part := range ctx.Req.Header["Accept"] {
|
||||
if strings.Contains(part, "text/html") {
|
||||
|
@ -91,7 +91,7 @@ func (ctx *Context) CheckQuota(subject quota_model.LimitSubject, userID int64, u
|
|||
|
||||
// ctx.CheckQuota checks whether the user in question is within quota limits (API context)
|
||||
func (ctx *APIContext) CheckQuota(subject quota_model.LimitSubject, userID int64, username string) bool {
|
||||
ok, err := checkQuota(ctx.Base.originCtx, subject, userID, username, func(userID int64, username string) {
|
||||
ok, err := checkQuota(ctx.originCtx, subject, userID, username, func(userID int64, username string) {
|
||||
ctx.JSON(http.StatusRequestEntityTooLarge, APIQuotaExceeded{
|
||||
Message: "quota exceeded",
|
||||
UserID: userID,
|
||||
|
|
|
@ -83,7 +83,7 @@ func (r *Repository) CanEnableEditor(ctx context.Context, user *user_model.User)
|
|||
|
||||
// CanCreateBranch returns true if repository is editable and user has proper access level.
|
||||
func (r *Repository) CanCreateBranch() bool {
|
||||
return r.Permission.CanWrite(unit_model.TypeCode) && r.Repository.CanCreateBranch()
|
||||
return r.CanWrite(unit_model.TypeCode) && r.Repository.CanCreateBranch()
|
||||
}
|
||||
|
||||
func (r *Repository) GetObjectFormat() git.ObjectFormat {
|
||||
|
@ -160,12 +160,12 @@ func (r *Repository) CanUseTimetracker(ctx context.Context, issue *issues_model.
|
|||
// 2. Is the user a contributor, admin, poster or assignee and do the repository policies require this?
|
||||
isAssigned, _ := issues_model.IsUserAssignedToIssue(ctx, issue, user)
|
||||
return r.Repository.IsTimetrackerEnabled(ctx) && (!r.Repository.AllowOnlyContributorsToTrackTime(ctx) ||
|
||||
r.Permission.CanWriteIssuesOrPulls(issue.IsPull) || issue.IsPoster(user.ID) || isAssigned)
|
||||
r.CanWriteIssuesOrPulls(issue.IsPull) || issue.IsPoster(user.ID) || isAssigned)
|
||||
}
|
||||
|
||||
// CanCreateIssueDependencies returns whether or not a user can create dependencies.
|
||||
func (r *Repository) CanCreateIssueDependencies(ctx context.Context, user *user_model.User, isPull bool) bool {
|
||||
return r.Repository.IsDependenciesEnabled(ctx) && r.Permission.CanWriteIssuesOrPulls(isPull)
|
||||
return r.Repository.IsDependenciesEnabled(ctx) && r.CanWriteIssuesOrPulls(isPull)
|
||||
}
|
||||
|
||||
// GetCommitsCount returns cached commit count for current view
|
||||
|
@ -378,7 +378,7 @@ func repoAssignment(ctx *Context, repo *repo_model.Repository) {
|
|||
}
|
||||
|
||||
// Check access.
|
||||
if !ctx.Repo.Permission.HasAccess() {
|
||||
if !ctx.Repo.HasAccess() {
|
||||
if ctx.FormString("go-get") == "1" {
|
||||
EarlyResponseForGoGetMeta(ctx)
|
||||
return
|
||||
|
|
|
@ -76,14 +76,15 @@ func Verify(buf []byte, fileName, allowedTypesStr string) error {
|
|||
|
||||
// AddUploadContext renders template values for dropzone
|
||||
func AddUploadContext(ctx *context.Context, uploadType string) {
|
||||
if uploadType == "release" {
|
||||
switch uploadType {
|
||||
case "release":
|
||||
ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/releases/attachments"
|
||||
ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/releases/attachments/remove"
|
||||
ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/releases/attachments"
|
||||
ctx.Data["UploadAccepts"] = strings.ReplaceAll(setting.Repository.Release.AllowedTypes, "|", ",")
|
||||
ctx.Data["UploadMaxFiles"] = setting.Attachment.MaxFiles
|
||||
ctx.Data["UploadMaxSize"] = setting.Attachment.MaxSize
|
||||
} else if uploadType == "comment" {
|
||||
case "comment":
|
||||
ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/issues/attachments"
|
||||
ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/issues/attachments/remove"
|
||||
if len(ctx.Params(":index")) > 0 {
|
||||
|
@ -94,7 +95,7 @@ func AddUploadContext(ctx *context.Context, uploadType string) {
|
|||
ctx.Data["UploadAccepts"] = strings.ReplaceAll(setting.Attachment.AllowedTypes, "|", ",")
|
||||
ctx.Data["UploadMaxFiles"] = setting.Attachment.MaxFiles
|
||||
ctx.Data["UploadMaxSize"] = setting.Attachment.MaxSize
|
||||
} else if uploadType == "repo" {
|
||||
case "repo":
|
||||
ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/upload-file"
|
||||
ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/upload-remove"
|
||||
ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/upload-file"
|
||||
|
|
|
@ -68,7 +68,7 @@ func MockContext(t *testing.T, reqPath string, opts ...MockContextOption) (*cont
|
|||
ctx.PageData = map[string]any{}
|
||||
ctx.Data["PageStartTime"] = time.Now()
|
||||
chiCtx := chi.NewRouteContext()
|
||||
ctx.Base.AppendContextValue(chi.RouteCtxKey, chiCtx)
|
||||
ctx.AppendContextValue(chi.RouteCtxKey, chiCtx)
|
||||
return ctx, resp
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ func MockAPIContext(t *testing.T, reqPath string) (*context.APIContext, *httptes
|
|||
_ = baseCleanUp // during test, it doesn't need to do clean up. TODO: this can be improved later
|
||||
|
||||
chiCtx := chi.NewRouteContext()
|
||||
ctx.Base.AppendContextValue(chi.RouteCtxKey, chiCtx)
|
||||
ctx.AppendContextValue(chi.RouteCtxKey, chiCtx)
|
||||
return ctx, resp
|
||||
}
|
||||
|
||||
|
@ -96,7 +96,7 @@ func MockPrivateContext(t *testing.T, reqPath string) (*context.PrivateContext,
|
|||
ctx := &context.PrivateContext{Base: base}
|
||||
_ = baseCleanUp // during test, it doesn't need to do clean up. TODO: this can be improved later
|
||||
chiCtx := chi.NewRouteContext()
|
||||
ctx.Base.AppendContextValue(chi.RouteCtxKey, chiCtx)
|
||||
ctx.AppendContextValue(chi.RouteCtxKey, chiCtx)
|
||||
return ctx, resp
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ func TestToCommitMeta(t *testing.T) {
|
|||
commitMeta := ToCommitMeta(headRepo, tag)
|
||||
|
||||
assert.NotNil(t, commitMeta)
|
||||
assert.EqualValues(t, &api.CommitMeta{
|
||||
assert.Equal(t, &api.CommitMeta{
|
||||
SHA: sha1.EmptyObjectID().String(),
|
||||
URL: util.URLJoin(headRepo.APIURL(), "git/commits", sha1.EmptyObjectID().String()),
|
||||
Created: time.Unix(0, 0),
|
||||
|
|
|
@ -17,7 +17,7 @@ import (
|
|||
func ToNotificationThread(ctx context.Context, n *activities_model.Notification) *api.NotificationThread {
|
||||
result := &api.NotificationThread{
|
||||
ID: n.ID,
|
||||
Unread: !(n.Status == activities_model.NotificationStatusRead || n.Status == activities_model.NotificationStatusPinned),
|
||||
Unread: n.Status != activities_model.NotificationStatusRead && n.Status != activities_model.NotificationStatusPinned,
|
||||
Pinned: n.Status == activities_model.NotificationStatusPinned,
|
||||
UpdatedAt: n.UpdatedUnix.AsTime(),
|
||||
URL: n.APIURL(),
|
||||
|
|
|
@ -66,7 +66,7 @@ func ToPullReviewList(ctx context.Context, rl []*issues_model.Review, doer *user
|
|||
result := make([]*api.PullReview, 0, len(rl))
|
||||
for i := range rl {
|
||||
// show pending reviews only for the user who created them
|
||||
if rl[i].Type == issues_model.ReviewTypePending && (doer == nil || !(doer.IsAdmin || doer.ID == rl[i].ReviewerID)) {
|
||||
if rl[i].Type == issues_model.ReviewTypePending && (doer == nil || (!doer.IsAdmin && doer.ID != rl[i].ReviewerID)) {
|
||||
continue
|
||||
}
|
||||
r, err := ToPullReview(ctx, rl[i], doer)
|
||||
|
|
|
@ -29,7 +29,7 @@ func TestPullRequest_APIFormat(t *testing.T) {
|
|||
require.NoError(t, pr.LoadIssue(db.DefaultContext))
|
||||
apiPullRequest := ToAPIPullRequest(git.DefaultContext, pr, nil)
|
||||
assert.NotNil(t, apiPullRequest)
|
||||
assert.EqualValues(t, &structs.PRBranchInfo{
|
||||
assert.Equal(t, &structs.PRBranchInfo{
|
||||
Name: "branch1",
|
||||
Ref: "refs/pull/2/head",
|
||||
Sha: "4a357436d925b5c974181ff12a994538ddc5a269",
|
||||
|
|
|
@ -24,6 +24,6 @@ func TestRelease_ToRelease(t *testing.T) {
|
|||
apiRelease := ToAPIRelease(db.DefaultContext, repo1, release1)
|
||||
assert.NotNil(t, apiRelease)
|
||||
assert.EqualValues(t, 1, apiRelease.ID)
|
||||
assert.EqualValues(t, "https://try.gitea.io/api/v1/repos/user2/repo1/releases/1", apiRelease.URL)
|
||||
assert.EqualValues(t, "https://try.gitea.io/api/v1/repos/user2/repo1/releases/1/assets", apiRelease.UploadURL)
|
||||
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/releases/1", apiRelease.URL)
|
||||
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/releases/1/assets", apiRelease.UploadURL)
|
||||
}
|
||||
|
|
|
@ -31,11 +31,11 @@ func TestUser_ToUser(t *testing.T) {
|
|||
|
||||
apiUser = toUser(db.DefaultContext, user1, false, false)
|
||||
assert.False(t, apiUser.IsAdmin)
|
||||
assert.EqualValues(t, api.VisibleTypePublic.String(), apiUser.Visibility)
|
||||
assert.Equal(t, api.VisibleTypePublic.String(), apiUser.Visibility)
|
||||
|
||||
user31 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 31, IsAdmin: false, Visibility: api.VisibleTypePrivate})
|
||||
|
||||
apiUser = toUser(db.DefaultContext, user31, true, true)
|
||||
assert.False(t, apiUser.IsAdmin)
|
||||
assert.EqualValues(t, api.VisibleTypePrivate.String(), apiUser.Visibility)
|
||||
assert.Equal(t, api.VisibleTypePrivate.String(), apiUser.Visibility)
|
||||
}
|
||||
|
|
|
@ -10,10 +10,10 @@ import (
|
|||
)
|
||||
|
||||
func TestToCorrectPageSize(t *testing.T) {
|
||||
assert.EqualValues(t, 30, ToCorrectPageSize(0))
|
||||
assert.EqualValues(t, 30, ToCorrectPageSize(-10))
|
||||
assert.EqualValues(t, 20, ToCorrectPageSize(20))
|
||||
assert.EqualValues(t, 50, ToCorrectPageSize(100))
|
||||
assert.Equal(t, 30, ToCorrectPageSize(0))
|
||||
assert.Equal(t, 30, ToCorrectPageSize(-10))
|
||||
assert.Equal(t, 20, ToCorrectPageSize(20))
|
||||
assert.Equal(t, 50, ToCorrectPageSize(100))
|
||||
}
|
||||
|
||||
func TestToGitServiceType(t *testing.T) {
|
||||
|
|
|
@ -221,7 +221,7 @@ func Test_fixPullRequestsConfig_16961(t *testing.T) {
|
|||
if gotFixed != tt.wantFixed {
|
||||
t.Errorf("fixPullRequestsConfig_16961() = %v, want %v", gotFixed, tt.wantFixed)
|
||||
}
|
||||
assert.EqualValues(t, &tt.expected, cfg)
|
||||
assert.Equal(t, &tt.expected, cfg)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -265,7 +265,7 @@ func Test_fixIssuesConfig_16961(t *testing.T) {
|
|||
if gotFixed != tt.wantFixed {
|
||||
t.Errorf("fixIssuesConfig_16961() = %v, want %v", gotFixed, tt.wantFixed)
|
||||
}
|
||||
assert.EqualValues(t, &tt.expected, cfg)
|
||||
assert.Equal(t, &tt.expected, cfg)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ func TestF3UtilMessage(t *testing.T) {
|
|||
actual = fmt.Sprintf(message, args...)
|
||||
}, nil)
|
||||
logger.Message("EXPECTED %s", "MESSAGE")
|
||||
assert.EqualValues(t, expected, actual)
|
||||
assert.Equal(t, expected, actual)
|
||||
}
|
||||
|
||||
func TestF3UtilLogger(t *testing.T) {
|
||||
|
|
|
@ -1060,7 +1060,7 @@ func readFileName(rd *strings.Reader) (string, bool) {
|
|||
_, _ = fmt.Fscanf(rd, "%s ", &name)
|
||||
char, _ := rd.ReadByte()
|
||||
_ = rd.UnreadByte()
|
||||
for !(char == 0 || char == '"' || char == 'b') {
|
||||
for char != 0 && char != '"' && char != 'b' {
|
||||
var suffix string
|
||||
_, _ = fmt.Fscanf(rd, "%s ", &suffix)
|
||||
name += " " + suffix
|
||||
|
|
|
@ -14,13 +14,14 @@ import (
|
|||
// token is a html tag or entity, eg: "<span ...>", "</span>", "<"
|
||||
func extractHTMLToken(s string) (before, token, after string, valid bool) {
|
||||
for pos1 := 0; pos1 < len(s); pos1++ {
|
||||
if s[pos1] == '<' {
|
||||
switch s[pos1] {
|
||||
case '<':
|
||||
pos2 := strings.IndexByte(s[pos1:], '>')
|
||||
if pos2 == -1 {
|
||||
return "", "", s, false
|
||||
}
|
||||
return s[:pos1], s[pos1 : pos1+pos2+1], s[pos1+pos2+1:], true
|
||||
} else if s[pos1] == '&' {
|
||||
case '&':
|
||||
pos2 := strings.IndexByte(s[pos1:], ';')
|
||||
if pos2 == -1 {
|
||||
return "", "", s, false
|
||||
|
|
|
@ -43,7 +43,7 @@ func TestDiffWithHighlight(t *testing.T) {
|
|||
|
||||
diff.Text = "C"
|
||||
hcd.recoverOneDiff(&diff)
|
||||
assert.Equal(t, "", diff.Text)
|
||||
assert.Empty(t, diff.Text)
|
||||
}
|
||||
|
||||
func TestDiffWithHighlightPlaceholder(t *testing.T) {
|
||||
|
@ -53,8 +53,8 @@ func TestDiffWithHighlightPlaceholder(t *testing.T) {
|
|||
"a='\U00100000'",
|
||||
"a='\U0010FFFD''",
|
||||
)
|
||||
assert.Equal(t, "", hcd.PlaceholderTokenMap[0x00100000])
|
||||
assert.Equal(t, "", hcd.PlaceholderTokenMap[0x0010FFFD])
|
||||
assert.Empty(t, hcd.PlaceholderTokenMap[0x00100000])
|
||||
assert.Empty(t, hcd.PlaceholderTokenMap[0x0010FFFD])
|
||||
|
||||
expected := fmt.Sprintf(`<span class="nx">a</span><span class="o">=</span><span class="s1">'</span><span class="removed-code">%s</span>'`, "\U00100000")
|
||||
output := diffToHTML(hcd.lineWrapperTags, diffs, DiffLineDel)
|
||||
|
|
|
@ -48,9 +48,9 @@ func TestDeleteComment(t *testing.T) {
|
|||
// Reactions don't exist anymore for this comment.
|
||||
unittest.AssertNotExistsBean(t, &issues_model.Reaction{CommentID: comment.ID})
|
||||
// Number of comments was decreased.
|
||||
assert.EqualValues(t, issue.NumComments-1, unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: comment.IssueID}).NumComments)
|
||||
assert.Equal(t, issue.NumComments-1, unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: comment.IssueID}).NumComments)
|
||||
// A notification was fired for the deletion of this comment.
|
||||
assert.EqualValues(t, hookTaskCount+1, unittest.GetCount(t, &webhook_model.HookTask{}))
|
||||
assert.Equal(t, hookTaskCount+1, unittest.GetCount(t, &webhook_model.HookTask{}))
|
||||
})
|
||||
|
||||
t.Run("Comment of pending review", func(t *testing.T) {
|
||||
|
@ -59,7 +59,7 @@ func TestDeleteComment(t *testing.T) {
|
|||
// We have to ensure that this comment's linked review is pending.
|
||||
comment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 4}, "review_id != 0")
|
||||
review := unittest.AssertExistsAndLoadBean(t, &issues_model.Review{ID: comment.ReviewID})
|
||||
assert.EqualValues(t, issues_model.ReviewTypePending, review.Type)
|
||||
assert.Equal(t, issues_model.ReviewTypePending, review.Type)
|
||||
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: comment.IssueID})
|
||||
|
||||
require.NoError(t, webhook_model.CreateWebhook(db.DefaultContext, &webhook_model.Webhook{
|
||||
|
@ -74,9 +74,9 @@ func TestDeleteComment(t *testing.T) {
|
|||
// The comment doesn't exist anymore.
|
||||
unittest.AssertNotExistsBean(t, &issues_model.Comment{ID: comment.ID})
|
||||
// Ensure that the number of comments wasn't decreased.
|
||||
assert.EqualValues(t, issue.NumComments, unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: comment.IssueID}).NumComments)
|
||||
assert.Equal(t, issue.NumComments, unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: comment.IssueID}).NumComments)
|
||||
// No notification was fired for the deletion of this comment.
|
||||
assert.EqualValues(t, hookTaskCount, unittest.GetCount(t, &webhook_model.HookTask{}))
|
||||
assert.Equal(t, hookTaskCount, unittest.GetCount(t, &webhook_model.HookTask{}))
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -105,11 +105,11 @@ func TestUpdateComment(t *testing.T) {
|
|||
|
||||
newComment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 2})
|
||||
// Content was updated.
|
||||
assert.EqualValues(t, comment.Content, newComment.Content)
|
||||
assert.Equal(t, comment.Content, newComment.Content)
|
||||
// Content version was updated.
|
||||
assert.EqualValues(t, 2, newComment.ContentVersion)
|
||||
assert.Equal(t, 2, newComment.ContentVersion)
|
||||
// A notification was fired for the update of this comment.
|
||||
assert.EqualValues(t, hookTaskCount+1, unittest.GetCount(t, &webhook_model.HookTask{}))
|
||||
assert.Equal(t, hookTaskCount+1, unittest.GetCount(t, &webhook_model.HookTask{}))
|
||||
// Issue history was saved for this comment.
|
||||
unittest.AssertExistsAndLoadBean(t, &issues_model.ContentHistory{CommentID: comment.ID, IsFirstCreated: true, ContentText: oldContent})
|
||||
unittest.AssertExistsAndLoadBean(t, &issues_model.ContentHistory{CommentID: comment.ID, ContentText: comment.Content}, "is_first_created = false")
|
||||
|
@ -120,7 +120,7 @@ func TestUpdateComment(t *testing.T) {
|
|||
|
||||
comment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 4}, "review_id != 0")
|
||||
review := unittest.AssertExistsAndLoadBean(t, &issues_model.Review{ID: comment.ReviewID})
|
||||
assert.EqualValues(t, issues_model.ReviewTypePending, review.Type)
|
||||
assert.Equal(t, issues_model.ReviewTypePending, review.Type)
|
||||
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: comment.IssueID})
|
||||
unittest.AssertNotExistsBean(t, &issues_model.ContentHistory{CommentID: comment.ID})
|
||||
require.NoError(t, webhook_model.CreateWebhook(db.DefaultContext, &webhook_model.Webhook{
|
||||
|
@ -136,11 +136,11 @@ func TestUpdateComment(t *testing.T) {
|
|||
|
||||
newComment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 2})
|
||||
// Content was updated.
|
||||
assert.EqualValues(t, comment.Content, newComment.Content)
|
||||
assert.Equal(t, comment.Content, newComment.Content)
|
||||
// Content version was updated.
|
||||
assert.EqualValues(t, 2, newComment.ContentVersion)
|
||||
assert.Equal(t, 2, newComment.ContentVersion)
|
||||
// No notification was fired for the update of this comment.
|
||||
assert.EqualValues(t, hookTaskCount, unittest.GetCount(t, &webhook_model.HookTask{}))
|
||||
assert.Equal(t, hookTaskCount, unittest.GetCount(t, &webhook_model.HookTask{}))
|
||||
// Issue history was not saved for this comment.
|
||||
unittest.AssertNotExistsBean(t, &issues_model.ContentHistory{CommentID: comment.ID})
|
||||
})
|
||||
|
|
|
@ -25,8 +25,8 @@ func TestGetRefEndNamesAndURLs(t *testing.T) {
|
|||
repoLink := "/foo/bar"
|
||||
|
||||
endNames, urls := GetRefEndNamesAndURLs(issues, repoLink)
|
||||
assert.EqualValues(t, map[int64]string{1: "branch1", 2: "tag1", 3: "c0ffee"}, endNames)
|
||||
assert.EqualValues(t, map[int64]string{
|
||||
assert.Equal(t, map[int64]string{1: "branch1", 2: "tag1", 3: "c0ffee"}, endNames)
|
||||
assert.Equal(t, map[int64]string{
|
||||
1: repoLink + "/src/branch/branch1",
|
||||
2: repoLink + "/src/tag/tag1",
|
||||
3: repoLink + "/src/commit/c0ffee",
|
||||
|
|
|
@ -163,11 +163,12 @@ func BatchHandler(ctx *context.Context) {
|
|||
}
|
||||
|
||||
var isUpload bool
|
||||
if br.Operation == "upload" {
|
||||
switch br.Operation {
|
||||
case "upload":
|
||||
isUpload = true
|
||||
} else if br.Operation == "download" {
|
||||
case "download":
|
||||
isUpload = false
|
||||
} else {
|
||||
default:
|
||||
log.Trace("Attempt to BATCH with invalid operation: %s", br.Operation)
|
||||
writeStatus(ctx, http.StatusBadRequest)
|
||||
return
|
||||
|
|
|
@ -85,7 +85,7 @@ func mailIssueCommentToParticipants(ctx *mailCommentContext, mentions []*user_mo
|
|||
|
||||
// =========== Repo watchers ===========
|
||||
// Make repo watchers last, since it's likely the list with the most users
|
||||
if !(ctx.Issue.IsPull && ctx.Issue.PullRequest.IsWorkInProgress(ctx) && ctx.ActionType != activities_model.ActionCreatePullRequest) {
|
||||
if !ctx.Issue.IsPull || !ctx.Issue.PullRequest.IsWorkInProgress(ctx) || ctx.ActionType == activities_model.ActionCreatePullRequest {
|
||||
ids, err = repo_model.GetRepoWatchersIDs(ctx, ctx.Issue.RepoID)
|
||||
if err != nil {
|
||||
return fmt.Errorf("GetRepoWatchersIDs(%d): %w", ctx.Issue.RepoID, err)
|
||||
|
@ -137,9 +137,8 @@ func mailIssueCommentBatch(ctx *mailCommentContext, users []*user_model.User, vi
|
|||
}
|
||||
// At this point we exclude:
|
||||
// user that don't have all mails enabled or users only get mail on mention and this is one ...
|
||||
if !(user.EmailNotificationsPreference == user_model.EmailNotificationsEnabled ||
|
||||
user.EmailNotificationsPreference == user_model.EmailNotificationsAndYourOwn ||
|
||||
fromMention && user.EmailNotificationsPreference == user_model.EmailNotificationsOnMention) {
|
||||
if user.EmailNotificationsPreference != user_model.EmailNotificationsEnabled &&
|
||||
user.EmailNotificationsPreference != user_model.EmailNotificationsAndYourOwn && (!fromMention || user.EmailNotificationsPreference != user_model.EmailNotificationsOnMention) {
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
@ -518,7 +518,7 @@ func TestFromDisplayName(t *testing.T) {
|
|||
t.Run(tc.userDisplayName, func(t *testing.T) {
|
||||
user := &user_model.User{FullName: tc.userDisplayName, Name: "tmp"}
|
||||
got := fromDisplayName(user)
|
||||
assert.EqualValues(t, tc.fromDisplayName, got)
|
||||
assert.Equal(t, tc.fromDisplayName, got)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -535,7 +535,7 @@ func TestFromDisplayName(t *testing.T) {
|
|||
setting.Domain = oldDomain
|
||||
}()
|
||||
|
||||
assert.EqualValues(t, "Mister X (by Code IT on [code.it])", fromDisplayName(&user_model.User{FullName: "Mister X", Name: "tmp"}))
|
||||
assert.Equal(t, "Mister X (by Code IT on [code.it])", fromDisplayName(&user_model.User{FullName: "Mister X", Name: "tmp"}))
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -72,7 +72,7 @@ func TestToMessage(t *testing.T) {
|
|||
_, err := m1.ToMessage().WriteTo(buf)
|
||||
require.NoError(t, err)
|
||||
header, _ := extractMailHeaderAndContent(t, buf.String())
|
||||
assert.EqualValues(t, map[string]string{
|
||||
assert.Equal(t, map[string]string{
|
||||
"Content-Type": "multipart/alternative;",
|
||||
"Date": "Mon, 01 Jan 0001 00:00:00 +0000",
|
||||
"From": "\"Test Gitea\" <test@gitea.com>",
|
||||
|
@ -92,7 +92,7 @@ func TestToMessage(t *testing.T) {
|
|||
_, err = m1.ToMessage().WriteTo(buf)
|
||||
require.NoError(t, err)
|
||||
header, _ = extractMailHeaderAndContent(t, buf.String())
|
||||
assert.EqualValues(t, map[string]string{
|
||||
assert.Equal(t, map[string]string{
|
||||
"Content-Type": "multipart/alternative;",
|
||||
"Date": "Mon, 01 Jan 0001 00:00:00 +0000",
|
||||
"From": "\"Test Gitea\" <test@gitea.com>",
|
||||
|
|
|
@ -30,15 +30,16 @@ func (m *mailNotifier) CreateIssueComment(ctx context.Context, doer *user_model.
|
|||
issue *issues_model.Issue, comment *issues_model.Comment, mentions []*user_model.User,
|
||||
) {
|
||||
var act activities_model.ActionType
|
||||
if comment.Type == issues_model.CommentTypeClose {
|
||||
switch comment.Type {
|
||||
case issues_model.CommentTypeClose:
|
||||
act = activities_model.ActionCloseIssue
|
||||
} else if comment.Type == issues_model.CommentTypeReopen {
|
||||
case issues_model.CommentTypeReopen:
|
||||
act = activities_model.ActionReopenIssue
|
||||
} else if comment.Type == issues_model.CommentTypeComment {
|
||||
case issues_model.CommentTypeComment:
|
||||
act = activities_model.ActionCommentIssue
|
||||
} else if comment.Type == issues_model.CommentTypeCode {
|
||||
case issues_model.CommentTypeCode:
|
||||
act = activities_model.ActionCommentIssue
|
||||
} else if comment.Type == issues_model.CommentTypePullRequestPush {
|
||||
case issues_model.CommentTypePullRequestPush:
|
||||
act = 0
|
||||
}
|
||||
|
||||
|
@ -94,11 +95,12 @@ func (m *mailNotifier) NewPullRequest(ctx context.Context, pr *issues_model.Pull
|
|||
|
||||
func (m *mailNotifier) PullRequestReview(ctx context.Context, pr *issues_model.PullRequest, r *issues_model.Review, comment *issues_model.Comment, mentions []*user_model.User) {
|
||||
var act activities_model.ActionType
|
||||
if comment.Type == issues_model.CommentTypeClose {
|
||||
switch comment.Type {
|
||||
case issues_model.CommentTypeClose:
|
||||
act = activities_model.ActionCloseIssue
|
||||
} else if comment.Type == issues_model.CommentTypeReopen {
|
||||
case issues_model.CommentTypeReopen:
|
||||
act = activities_model.ActionReopenIssue
|
||||
} else if comment.Type == issues_model.CommentTypeComment {
|
||||
case issues_model.CommentTypeComment:
|
||||
act = activities_model.ActionCommentPull
|
||||
}
|
||||
if err := MailParticipantsComment(ctx, comment, act, pr.Issue, mentions); err != nil {
|
||||
|
|
|
@ -45,7 +45,7 @@ func TestGiteaDownloadRepo(t *testing.T) {
|
|||
topics, err := downloader.GetTopics()
|
||||
require.NoError(t, err)
|
||||
sort.Strings(topics)
|
||||
assert.EqualValues(t, []string{"ci", "gitea", "migration", "test"}, topics)
|
||||
assert.Equal(t, []string{"ci", "gitea", "migration", "test"}, topics)
|
||||
|
||||
labels, err := downloader.GetLabels()
|
||||
require.NoError(t, err)
|
||||
|
@ -132,7 +132,7 @@ func TestGiteaDownloadRepo(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.True(t, isEnd)
|
||||
assert.Len(t, issues, 7)
|
||||
assert.EqualValues(t, "open", issues[0].State)
|
||||
assert.Equal(t, "open", issues[0].State)
|
||||
|
||||
issues, isEnd, err = downloader.GetIssues(3, 2)
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -64,7 +64,7 @@ func TestGiteaUploadRepo(t *testing.T) {
|
|||
|
||||
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerID: user.ID, Name: repoName})
|
||||
assert.True(t, repo.HasWiki())
|
||||
assert.EqualValues(t, repo_model.RepositoryReady, repo.Status)
|
||||
assert.Equal(t, repo_model.RepositoryReady, repo.Status)
|
||||
|
||||
milestones, err := db.Find[issues_model.Milestone](db.DefaultContext, issues_model.FindMilestoneOptions{
|
||||
RepoID: repo.ID,
|
||||
|
@ -173,7 +173,7 @@ func TestGiteaUploadRemapLocalUser(t *testing.T) {
|
|||
uploader.userMap = make(map[int64]int64)
|
||||
err = uploader.remapUser(&source, &target)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, user.ID, target.GetUserID())
|
||||
assert.Equal(t, user.ID, target.GetUserID())
|
||||
}
|
||||
|
||||
func TestGiteaUploadRemapExternalUser(t *testing.T) {
|
||||
|
@ -224,7 +224,7 @@ func TestGiteaUploadRemapExternalUser(t *testing.T) {
|
|||
target = repo_model.Release{}
|
||||
err = uploader.remapUser(&source, &target)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, linkedUser.ID, target.GetUserID())
|
||||
assert.Equal(t, linkedUser.ID, target.GetUserID())
|
||||
}
|
||||
|
||||
func TestGiteaUploadUpdateGitForPullRequest(t *testing.T) {
|
||||
|
@ -504,14 +504,14 @@ func TestGiteaUploadUpdateGitForPullRequest(t *testing.T) {
|
|||
|
||||
head, err := uploader.updateGitForPullRequest(&testCase.pr)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, testCase.head, head)
|
||||
assert.Equal(t, testCase.head, head)
|
||||
|
||||
log.Info(stopMark)
|
||||
|
||||
logFiltered, logStopped := logChecker.Check(5 * time.Second)
|
||||
assert.True(t, logStopped)
|
||||
if len(testCase.logFilter) > 0 {
|
||||
assert.EqualValues(t, testCase.logFiltered, logFiltered, "for log message filters: %v", testCase.logFilter)
|
||||
assert.Equal(t, testCase.logFiltered, logFiltered, "for log message filters: %v", testCase.logFilter)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ func TestGitlabDownloadRepo(t *testing.T) {
|
|||
topics, err := downloader.GetTopics()
|
||||
require.NoError(t, err)
|
||||
assert.Len(t, topics, 2)
|
||||
assert.EqualValues(t, []string{"migration", "test"}, topics)
|
||||
assert.Equal(t, []string{"migration", "test"}, topics)
|
||||
|
||||
milestones, err := downloader.GetMilestones()
|
||||
require.NoError(t, err)
|
||||
|
@ -352,7 +352,7 @@ func TestGitlabSkippedIssueNumber(t *testing.T) {
|
|||
// the only issue in this repository has number 2
|
||||
assert.Len(t, issues, 1)
|
||||
assert.EqualValues(t, 2, issues[0].Number)
|
||||
assert.EqualValues(t, "vpn unlimited errors", issues[0].Title)
|
||||
assert.Equal(t, "vpn unlimited errors", issues[0].Title)
|
||||
|
||||
prs, _, err := downloader.GetPullRequests(1, 10)
|
||||
require.NoError(t, err)
|
||||
|
@ -361,7 +361,7 @@ func TestGitlabSkippedIssueNumber(t *testing.T) {
|
|||
// pull request 3 in Forgejo
|
||||
assert.Len(t, prs, 1)
|
||||
assert.EqualValues(t, 3, prs[0].Number)
|
||||
assert.EqualValues(t, "Review", prs[0].Title)
|
||||
assert.Equal(t, "Review", prs[0].Title)
|
||||
}
|
||||
|
||||
func gitlabClientMockSetup(t *testing.T) (*http.ServeMux, *httptest.Server, *gitlab.Client) {
|
||||
|
@ -531,7 +531,7 @@ func TestAwardsToReactions(t *testing.T) {
|
|||
require.NoError(t, json.Unmarshal([]byte(testResponse), &awards))
|
||||
|
||||
reactions := downloader.awardsToReactions(awards)
|
||||
assert.EqualValues(t, []*base.Reaction{
|
||||
assert.Equal(t, []*base.Reaction{
|
||||
{
|
||||
UserName: "lafriks",
|
||||
UserID: 1241334,
|
||||
|
@ -623,7 +623,7 @@ func TestNoteToComment(t *testing.T) {
|
|||
|
||||
for i, note := range notes {
|
||||
actualComment := *downloader.convertNoteToComment(17, ¬e)
|
||||
assert.EqualValues(t, actualComment, comments[i])
|
||||
assert.Equal(t, actualComment, comments[i])
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -215,9 +215,9 @@ func TestGogsDownloaderFactory_New(t *testing.T) {
|
|||
}
|
||||
|
||||
assert.IsType(t, &GogsDownloader{}, got)
|
||||
assert.EqualValues(t, tt.baseURL, got.(*GogsDownloader).baseURL)
|
||||
assert.EqualValues(t, tt.repoOwner, got.(*GogsDownloader).repoOwner)
|
||||
assert.EqualValues(t, tt.repoName, got.(*GogsDownloader).repoName)
|
||||
assert.Equal(t, tt.baseURL, got.(*GogsDownloader).baseURL)
|
||||
assert.Equal(t, tt.repoOwner, got.(*GogsDownloader).repoOwner)
|
||||
assert.Equal(t, tt.repoName, got.(*GogsDownloader).repoName)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,43 +24,43 @@ func Test_parseRemoteUpdateOutput(t *testing.T) {
|
|||
`
|
||||
results := parseRemoteUpdateOutput(output, "origin")
|
||||
assert.Len(t, results, 10)
|
||||
assert.EqualValues(t, "refs/tags/v0.1.8", results[0].refName.String())
|
||||
assert.EqualValues(t, gitShortEmptySha, results[0].oldCommitID)
|
||||
assert.EqualValues(t, "", results[0].newCommitID)
|
||||
assert.Equal(t, "refs/tags/v0.1.8", results[0].refName.String())
|
||||
assert.Equal(t, gitShortEmptySha, results[0].oldCommitID)
|
||||
assert.Empty(t, results[0].newCommitID)
|
||||
|
||||
assert.EqualValues(t, "refs/heads/master", results[1].refName.String())
|
||||
assert.EqualValues(t, gitShortEmptySha, results[1].oldCommitID)
|
||||
assert.EqualValues(t, "", results[1].newCommitID)
|
||||
assert.Equal(t, "refs/heads/master", results[1].refName.String())
|
||||
assert.Equal(t, gitShortEmptySha, results[1].oldCommitID)
|
||||
assert.Empty(t, results[1].newCommitID)
|
||||
|
||||
assert.EqualValues(t, "refs/heads/test1", results[2].refName.String())
|
||||
assert.EqualValues(t, "", results[2].oldCommitID)
|
||||
assert.EqualValues(t, gitShortEmptySha, results[2].newCommitID)
|
||||
assert.Equal(t, "refs/heads/test1", results[2].refName.String())
|
||||
assert.Empty(t, results[2].oldCommitID)
|
||||
assert.Equal(t, gitShortEmptySha, results[2].newCommitID)
|
||||
|
||||
assert.EqualValues(t, "refs/tags/tag1", results[3].refName.String())
|
||||
assert.EqualValues(t, "", results[3].oldCommitID)
|
||||
assert.EqualValues(t, gitShortEmptySha, results[3].newCommitID)
|
||||
assert.Equal(t, "refs/tags/tag1", results[3].refName.String())
|
||||
assert.Empty(t, results[3].oldCommitID)
|
||||
assert.Equal(t, gitShortEmptySha, results[3].newCommitID)
|
||||
|
||||
assert.EqualValues(t, "refs/heads/test2", results[4].refName.String())
|
||||
assert.EqualValues(t, "f895a1e", results[4].oldCommitID)
|
||||
assert.EqualValues(t, "957a993", results[4].newCommitID)
|
||||
assert.Equal(t, "refs/heads/test2", results[4].refName.String())
|
||||
assert.Equal(t, "f895a1e", results[4].oldCommitID)
|
||||
assert.Equal(t, "957a993", results[4].newCommitID)
|
||||
|
||||
assert.EqualValues(t, "refs/heads/test3", results[5].refName.String())
|
||||
assert.EqualValues(t, "957a993", results[5].oldCommitID)
|
||||
assert.EqualValues(t, "a87ba5f", results[5].newCommitID)
|
||||
assert.Equal(t, "refs/heads/test3", results[5].refName.String())
|
||||
assert.Equal(t, "957a993", results[5].oldCommitID)
|
||||
assert.Equal(t, "a87ba5f", results[5].newCommitID)
|
||||
|
||||
assert.EqualValues(t, "refs/pull/26595/head", results[6].refName.String())
|
||||
assert.EqualValues(t, gitShortEmptySha, results[6].oldCommitID)
|
||||
assert.EqualValues(t, "", results[6].newCommitID)
|
||||
assert.Equal(t, "refs/pull/26595/head", results[6].refName.String())
|
||||
assert.Equal(t, gitShortEmptySha, results[6].oldCommitID)
|
||||
assert.Empty(t, results[6].newCommitID)
|
||||
|
||||
assert.EqualValues(t, "refs/pull/26595/merge", results[7].refName.String())
|
||||
assert.EqualValues(t, gitShortEmptySha, results[7].oldCommitID)
|
||||
assert.EqualValues(t, "", results[7].newCommitID)
|
||||
assert.Equal(t, "refs/pull/26595/merge", results[7].refName.String())
|
||||
assert.Equal(t, gitShortEmptySha, results[7].oldCommitID)
|
||||
assert.Empty(t, results[7].newCommitID)
|
||||
|
||||
assert.EqualValues(t, "refs/pull/25873/head", results[8].refName.String())
|
||||
assert.EqualValues(t, "e0639e38fb", results[8].oldCommitID)
|
||||
assert.EqualValues(t, "6db2410489", results[8].newCommitID)
|
||||
assert.Equal(t, "refs/pull/25873/head", results[8].refName.String())
|
||||
assert.Equal(t, "e0639e38fb", results[8].oldCommitID)
|
||||
assert.Equal(t, "6db2410489", results[8].newCommitID)
|
||||
|
||||
assert.EqualValues(t, "refs/pull/25873/merge", results[9].refName.String())
|
||||
assert.EqualValues(t, "1c97ebc746", results[9].oldCommitID)
|
||||
assert.EqualValues(t, "976d27d52f", results[9].newCommitID)
|
||||
assert.Equal(t, "refs/pull/25873/merge", results[9].refName.String())
|
||||
assert.Equal(t, "1c97ebc746", results[9].oldCommitID)
|
||||
assert.Equal(t, "976d27d52f", results[9].newCommitID)
|
||||
}
|
||||
|
|
|
@ -122,23 +122,24 @@ func ExecuteCleanupRules(outerCtx context.Context) error {
|
|||
}
|
||||
|
||||
if anyVersionDeleted {
|
||||
if pcr.Type == packages_model.TypeDebian {
|
||||
switch pcr.Type {
|
||||
case packages_model.TypeDebian:
|
||||
if err := debian_service.BuildAllRepositoryFiles(ctx, pcr.OwnerID); err != nil {
|
||||
return fmt.Errorf("CleanupRule [%d]: debian.BuildAllRepositoryFiles failed: %w", pcr.ID, err)
|
||||
}
|
||||
} else if pcr.Type == packages_model.TypeAlpine {
|
||||
case packages_model.TypeAlpine:
|
||||
if err := alpine_service.BuildAllRepositoryFiles(ctx, pcr.OwnerID); err != nil {
|
||||
return fmt.Errorf("CleanupRule [%d]: alpine.BuildAllRepositoryFiles failed: %w", pcr.ID, err)
|
||||
}
|
||||
} else if pcr.Type == packages_model.TypeRpm {
|
||||
case packages_model.TypeRpm:
|
||||
if err := rpm_service.BuildAllRepositoryFiles(ctx, pcr.OwnerID); err != nil {
|
||||
return fmt.Errorf("CleanupRule [%d]: rpm.BuildAllRepositoryFiles failed: %w", pcr.ID, err)
|
||||
}
|
||||
} else if pcr.Type == packages_model.TypeArch {
|
||||
case packages_model.TypeArch:
|
||||
if err := arch_service.BuildAllRepositoryFiles(ctx, pcr.OwnerID); err != nil {
|
||||
return fmt.Errorf("CleanupRule [%d]: arch.BuildAllRepositoryFiles failed: %w", pcr.ID, err)
|
||||
}
|
||||
} else if pcr.Type == packages_model.TypeAlt {
|
||||
case packages_model.TypeAlt:
|
||||
if err := alt_service.BuildAllRepositoryFiles(ctx, pcr.OwnerID); err != nil {
|
||||
return fmt.Errorf("CleanupRule [%d]: alt.BuildAllRepositoryFiles failed: %w", pcr.ID, err)
|
||||
}
|
||||
|
|
|
@ -78,7 +78,7 @@ func TestCleanupSHA256(t *testing.T) {
|
|||
for range expected {
|
||||
filtered = append(filtered, true)
|
||||
}
|
||||
assert.EqualValues(t, filtered, logFiltered, expected)
|
||||
assert.Equal(t, filtered, logFiltered, expected)
|
||||
}
|
||||
|
||||
ancient := 1 * time.Hour
|
||||
|
|
|
@ -92,7 +92,7 @@ func (u *BlobUploader) Append(ctx context.Context, r io.Reader) error {
|
|||
|
||||
u.BytesReceived += n
|
||||
|
||||
u.HashStateBytes, err = u.MultiHasher.MarshalBinary()
|
||||
u.HashStateBytes, err = u.MarshalBinary()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ func TestPullRequest_AddToTaskQueue(t *testing.T) {
|
|||
|
||||
select {
|
||||
case id := <-idChan:
|
||||
assert.EqualValues(t, pr.ID, id)
|
||||
assert.Equal(t, pr.ID, id)
|
||||
case <-time.After(time.Second):
|
||||
assert.FailNow(t, "Timeout: nothing was added to pullRequestQueue")
|
||||
}
|
||||
|
|
|
@ -232,7 +232,7 @@ func CreateCodeCommentKnownReviewID(ctx context.Context, doer *user_model.User,
|
|||
commit, err := gitRepo.LineBlame(head, gitRepo.Path, treePath, uint(line))
|
||||
if err == nil {
|
||||
commitID = commit.ID.String()
|
||||
} else if !(strings.Contains(err.Error(), "exit status 128 - fatal: no such path") || notEnoughLines.MatchString(err.Error())) {
|
||||
} else if !strings.Contains(err.Error(), "exit status 128 - fatal: no such path") && !notEnoughLines.MatchString(err.Error()) {
|
||||
return nil, fmt.Errorf("LineBlame[%s, %s, %s, %d]: %w", pr.GetGitRefName(), gitRepo.Path, treePath, line, err)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -138,9 +138,9 @@ func TestRelease_Create(t *testing.T) {
|
|||
}))
|
||||
assert.NoError(t, repo_model.GetReleaseAttachments(db.DefaultContext, &release))
|
||||
assert.Len(t, release.Attachments, 1)
|
||||
assert.EqualValues(t, attach.UUID, release.Attachments[0].UUID)
|
||||
assert.EqualValues(t, attach.Name, release.Attachments[0].Name)
|
||||
assert.EqualValues(t, attach.ExternalURL, release.Attachments[0].ExternalURL)
|
||||
assert.Equal(t, attach.UUID, release.Attachments[0].UUID)
|
||||
assert.Equal(t, attach.Name, release.Attachments[0].Name)
|
||||
assert.Equal(t, attach.ExternalURL, release.Attachments[0].ExternalURL)
|
||||
|
||||
release = repo_model.Release{
|
||||
RepoID: repo.ID,
|
||||
|
@ -165,8 +165,8 @@ func TestRelease_Create(t *testing.T) {
|
|||
}))
|
||||
assert.NoError(t, repo_model.GetReleaseAttachments(db.DefaultContext, &release))
|
||||
assert.Len(t, release.Attachments, 1)
|
||||
assert.EqualValues(t, "test", release.Attachments[0].Name)
|
||||
assert.EqualValues(t, "https://forgejo.org/", release.Attachments[0].ExternalURL)
|
||||
assert.Equal(t, "test", release.Attachments[0].Name)
|
||||
assert.Equal(t, "https://forgejo.org/", release.Attachments[0].ExternalURL)
|
||||
|
||||
release = repo_model.Release{
|
||||
RepoID: repo.ID,
|
||||
|
@ -318,10 +318,10 @@ func TestRelease_Update(t *testing.T) {
|
|||
}))
|
||||
require.NoError(t, repo_model.GetReleaseAttachments(db.DefaultContext, release))
|
||||
assert.Len(t, release.Attachments, 1)
|
||||
assert.EqualValues(t, attach.UUID, release.Attachments[0].UUID)
|
||||
assert.EqualValues(t, release.ID, release.Attachments[0].ReleaseID)
|
||||
assert.EqualValues(t, attach.Name, release.Attachments[0].Name)
|
||||
assert.EqualValues(t, attach.ExternalURL, release.Attachments[0].ExternalURL)
|
||||
assert.Equal(t, attach.UUID, release.Attachments[0].UUID)
|
||||
assert.Equal(t, release.ID, release.Attachments[0].ReleaseID)
|
||||
assert.Equal(t, attach.Name, release.Attachments[0].Name)
|
||||
assert.Equal(t, attach.ExternalURL, release.Attachments[0].ExternalURL)
|
||||
|
||||
// update the attachment name
|
||||
require.NoError(t, UpdateRelease(db.DefaultContext, user, gitRepo, release, false, []*AttachmentChange{
|
||||
|
@ -334,10 +334,10 @@ func TestRelease_Update(t *testing.T) {
|
|||
release.Attachments = nil
|
||||
require.NoError(t, repo_model.GetReleaseAttachments(db.DefaultContext, release))
|
||||
assert.Len(t, release.Attachments, 1)
|
||||
assert.EqualValues(t, attach.UUID, release.Attachments[0].UUID)
|
||||
assert.EqualValues(t, release.ID, release.Attachments[0].ReleaseID)
|
||||
assert.EqualValues(t, "test2.txt", release.Attachments[0].Name)
|
||||
assert.EqualValues(t, attach.ExternalURL, release.Attachments[0].ExternalURL)
|
||||
assert.Equal(t, attach.UUID, release.Attachments[0].UUID)
|
||||
assert.Equal(t, release.ID, release.Attachments[0].ReleaseID)
|
||||
assert.Equal(t, "test2.txt", release.Attachments[0].Name)
|
||||
assert.Equal(t, attach.ExternalURL, release.Attachments[0].ExternalURL)
|
||||
|
||||
// delete the attachment
|
||||
require.NoError(t, UpdateRelease(db.DefaultContext, user, gitRepo, release, false, []*AttachmentChange{
|
||||
|
@ -361,9 +361,9 @@ func TestRelease_Update(t *testing.T) {
|
|||
}))
|
||||
assert.NoError(t, repo_model.GetReleaseAttachments(db.DefaultContext, release))
|
||||
assert.Len(t, release.Attachments, 1)
|
||||
assert.EqualValues(t, release.ID, release.Attachments[0].ReleaseID)
|
||||
assert.EqualValues(t, "test", release.Attachments[0].Name)
|
||||
assert.EqualValues(t, "https://forgejo.org/", release.Attachments[0].ExternalURL)
|
||||
assert.Equal(t, release.ID, release.Attachments[0].ReleaseID)
|
||||
assert.Equal(t, "test", release.Attachments[0].Name)
|
||||
assert.Equal(t, "https://forgejo.org/", release.Attachments[0].ExternalURL)
|
||||
externalAttachmentUUID := release.Attachments[0].UUID
|
||||
|
||||
// update the attachment name
|
||||
|
@ -378,10 +378,10 @@ func TestRelease_Update(t *testing.T) {
|
|||
release.Attachments = nil
|
||||
assert.NoError(t, repo_model.GetReleaseAttachments(db.DefaultContext, release))
|
||||
assert.Len(t, release.Attachments, 1)
|
||||
assert.EqualValues(t, externalAttachmentUUID, release.Attachments[0].UUID)
|
||||
assert.EqualValues(t, release.ID, release.Attachments[0].ReleaseID)
|
||||
assert.EqualValues(t, "test2", release.Attachments[0].Name)
|
||||
assert.EqualValues(t, "https://about.gitea.com/", release.Attachments[0].ExternalURL)
|
||||
assert.Equal(t, externalAttachmentUUID, release.Attachments[0].UUID)
|
||||
assert.Equal(t, release.ID, release.Attachments[0].ReleaseID)
|
||||
assert.Equal(t, "test2", release.Attachments[0].Name)
|
||||
assert.Equal(t, "https://about.gitea.com/", release.Attachments[0].ExternalURL)
|
||||
}
|
||||
|
||||
func TestRelease_createTag(t *testing.T) {
|
||||
|
|
|
@ -36,7 +36,7 @@ func TestArchive_Basic(t *testing.T) {
|
|||
bogusReq, err := NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit, git.ZIP)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, bogusReq)
|
||||
assert.EqualValues(t, firstCommit+".zip", bogusReq.GetArchiveName())
|
||||
assert.Equal(t, firstCommit+".zip", bogusReq.GetArchiveName())
|
||||
|
||||
// Check a series of bogus requests.
|
||||
// Step 1, valid commit with a bad extension.
|
||||
|
@ -57,12 +57,12 @@ func TestArchive_Basic(t *testing.T) {
|
|||
bogusReq, err = NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, "master", git.ZIP)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, bogusReq)
|
||||
assert.EqualValues(t, "master.zip", bogusReq.GetArchiveName())
|
||||
assert.Equal(t, "master.zip", bogusReq.GetArchiveName())
|
||||
|
||||
bogusReq, err = NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, "test/archive", git.ZIP)
|
||||
require.NoError(t, err)
|
||||
assert.NotNil(t, bogusReq)
|
||||
assert.EqualValues(t, "test-archive.zip", bogusReq.GetArchiveName())
|
||||
assert.Equal(t, "test-archive.zip", bogusReq.GetArchiveName())
|
||||
|
||||
// Now two valid requests, firstCommit with valid extensions.
|
||||
zipReq, err := NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit, git.ZIP)
|
||||
|
|
|
@ -60,7 +60,7 @@ func TestDeleteAvatar(t *testing.T) {
|
|||
err = DeleteAvatar(db.DefaultContext, repo)
|
||||
require.NoError(t, err)
|
||||
|
||||
assert.Equal(t, "", repo.Avatar)
|
||||
assert.Empty(t, repo.Avatar)
|
||||
}
|
||||
|
||||
func TestTemplateGenerateAvatar(t *testing.T) {
|
||||
|
|
|
@ -53,14 +53,14 @@ func TestRepository_ContributorsGraph(t *testing.T) {
|
|||
keys = append(keys, k)
|
||||
}
|
||||
slices.Sort(keys)
|
||||
assert.EqualValues(t, []string{
|
||||
assert.Equal(t, []string{
|
||||
"ethantkoenig@gmail.com",
|
||||
"jimmy.praet@telenet.be",
|
||||
"jon@allspice.io",
|
||||
"total", // generated summary
|
||||
}, keys)
|
||||
|
||||
assert.EqualValues(t, &ContributorData{
|
||||
assert.Equal(t, &ContributorData{
|
||||
Name: "Ethan Koenig",
|
||||
AvatarLink: "/assets/img/avatar_default.png",
|
||||
TotalCommits: 1,
|
||||
|
@ -73,7 +73,7 @@ func TestRepository_ContributorsGraph(t *testing.T) {
|
|||
},
|
||||
},
|
||||
}, data["ethantkoenig@gmail.com"])
|
||||
assert.EqualValues(t, &ContributorData{
|
||||
assert.Equal(t, &ContributorData{
|
||||
Name: "Total",
|
||||
AvatarLink: "",
|
||||
TotalCommits: 3,
|
||||
|
|
|
@ -64,13 +64,13 @@ func TestGetContents(t *testing.T) {
|
|||
|
||||
t.Run("Get README.md contents with GetContents(ctx, )", func(t *testing.T) {
|
||||
fileContentResponse, err := GetContents(db.DefaultContext, repo, treePath, ref, false)
|
||||
assert.EqualValues(t, expectedContentsResponse, fileContentResponse)
|
||||
assert.Equal(t, expectedContentsResponse, fileContentResponse)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
|
||||
t.Run("Get README.md contents with ref as empty string (should then use the repo's default branch) with GetContents(ctx, )", func(t *testing.T) {
|
||||
fileContentResponse, err := GetContents(db.DefaultContext, repo, treePath, "", false)
|
||||
assert.EqualValues(t, expectedContentsResponse, fileContentResponse)
|
||||
assert.Equal(t, expectedContentsResponse, fileContentResponse)
|
||||
require.NoError(t, err)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -124,7 +124,7 @@ func TestGetDiffPreview(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
bs, err := json.Marshal(diff)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, string(expectedBs), string(bs))
|
||||
assert.Equal(t, string(expectedBs), string(bs))
|
||||
})
|
||||
|
||||
t.Run("empty branch, same results", func(t *testing.T) {
|
||||
|
@ -134,7 +134,7 @@ func TestGetDiffPreview(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
bs, err := json.Marshal(diff)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, expectedBs, bs)
|
||||
assert.Equal(t, expectedBs, bs)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -14,13 +14,13 @@ func TestCleanUploadFileName(t *testing.T) {
|
|||
name := "this/is/test"
|
||||
cleanName := CleanUploadFileName(name)
|
||||
expectedCleanName := name
|
||||
assert.EqualValues(t, expectedCleanName, cleanName)
|
||||
assert.Equal(t, expectedCleanName, cleanName)
|
||||
})
|
||||
|
||||
t.Run("Clean a .git path", func(t *testing.T) {
|
||||
name := "this/is/test/.git"
|
||||
cleanName := CleanUploadFileName(name)
|
||||
expectedCleanName := ""
|
||||
assert.EqualValues(t, expectedCleanName, cleanName)
|
||||
assert.Equal(t, expectedCleanName, cleanName)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -48,5 +48,5 @@ func TestGetTreeBySHA(t *testing.T) {
|
|||
TotalCount: 1,
|
||||
}
|
||||
|
||||
assert.EqualValues(t, expectedTree, tree)
|
||||
assert.Equal(t, expectedTree, tree)
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ func GarbageCollectLFSMetaObjectsForRepo(ctx context.Context, repo *repo_model.R
|
|||
|
||||
err = git_model.IterateLFSMetaObjectsForRepo(ctx, repo.ID, func(ctx context.Context, metaObject *git_model.LFSMetaObject) error {
|
||||
total++
|
||||
pointerSha := git.ComputeBlobHash(objectFormat, []byte(metaObject.Pointer.StringContent()))
|
||||
pointerSha := git.ComputeBlobHash(objectFormat, []byte(metaObject.StringContent()))
|
||||
|
||||
if gitRepo.IsObjectExist(pointerSha.String()) {
|
||||
return git_model.MarkLFSMetaObject(ctx, metaObject.ID)
|
||||
|
|
|
@ -42,7 +42,7 @@ func TestUserDeleteAvatar(t *testing.T) {
|
|||
err := UploadAvatar(db.DefaultContext, user, buff.Bytes())
|
||||
require.NoError(t, err)
|
||||
verification := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||
assert.NotEqual(t, "", verification.Avatar)
|
||||
assert.NotEmpty(t, verification.Avatar)
|
||||
|
||||
// fail to delete ...
|
||||
storage.Avatars = storage.UninitializedStorage
|
||||
|
@ -60,7 +60,7 @@ func TestUserDeleteAvatar(t *testing.T) {
|
|||
|
||||
// ... the avatar is removed from the database
|
||||
verification = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||
assert.Equal(t, "", verification.Avatar)
|
||||
assert.Empty(t, verification.Avatar)
|
||||
})
|
||||
|
||||
t.Run("Success", func(t *testing.T) {
|
||||
|
@ -70,12 +70,12 @@ func TestUserDeleteAvatar(t *testing.T) {
|
|||
err := UploadAvatar(db.DefaultContext, user, buff.Bytes())
|
||||
require.NoError(t, err)
|
||||
verification := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||
assert.NotEqual(t, "", verification.Avatar)
|
||||
assert.NotEmpty(t, verification.Avatar)
|
||||
|
||||
err = DeleteAvatar(db.DefaultContext, user)
|
||||
require.NoError(t, err)
|
||||
|
||||
verification = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
|
||||
assert.Equal(t, "", verification.Avatar)
|
||||
assert.Empty(t, verification.Avatar)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -195,7 +195,7 @@ func TestRenameUser(t *testing.T) {
|
|||
|
||||
redirectUID, err := user_model.LookupUserRedirect(db.DefaultContext, oldUsername)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, user.ID, redirectUID)
|
||||
assert.Equal(t, user.ID, redirectUID)
|
||||
|
||||
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerID: user.ID, OwnerName: user.Name})
|
||||
})
|
||||
|
|
|
@ -237,7 +237,7 @@ func TestOpenProjectPayload(t *testing.T) {
|
|||
assert.Equal(t, 12, j.Get("number").MustBeValid().ToInt())
|
||||
assert.Equal(t, "http://localhost:3000/test/repo/pulls/12", j.Get("html_url").MustBeValid().ToString())
|
||||
assert.Equal(t, jsoniter.NilValue, j.Get("updated_at").ValueType())
|
||||
assert.Equal(t, "", j.Get("state").MustBeValid().ToString())
|
||||
assert.Empty(t, j.Get("state").MustBeValid().ToString())
|
||||
assert.Equal(t, "Fix bug", j.Get("title").MustBeValid().ToString())
|
||||
assert.Equal(t, "fixes bug #2", j.Get("body").MustBeValid().ToString())
|
||||
|
||||
|
|
|
@ -137,7 +137,7 @@ func TestWebhookDeliverHookTask(t *testing.T) {
|
|||
case "/webhook/66d222a5d6349e1311f551e50722d837e30fce98":
|
||||
// Version 1
|
||||
assert.Equal(t, "push", r.Header.Get("X-GitHub-Event"))
|
||||
assert.Equal(t, "", r.Header.Get("Content-Type"))
|
||||
assert.Empty(t, r.Header.Get("Content-Type"))
|
||||
body, err := io.ReadAll(r.Body)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, `{"data": 42}`, string(body))
|
||||
|
|
|
@ -37,11 +37,12 @@ func getPullRequestInfo(p *api.PullRequestPayload) (title, link, by, operator, o
|
|||
for i, user := range assignList {
|
||||
assignStringList[i] = user.UserName
|
||||
}
|
||||
if p.Action == api.HookIssueAssigned {
|
||||
switch p.Action {
|
||||
case api.HookIssueAssigned:
|
||||
operateResult = fmt.Sprintf("%s assign this to %s", p.Sender.UserName, assignList[len(assignList)-1].UserName)
|
||||
} else if p.Action == api.HookIssueUnassigned {
|
||||
case api.HookIssueUnassigned:
|
||||
operateResult = fmt.Sprintf("%s unassigned this for someone", p.Sender.UserName)
|
||||
} else if p.Action == api.HookIssueMilestoned {
|
||||
case api.HookIssueMilestoned:
|
||||
operateResult = fmt.Sprintf("%s/milestone/%d", p.Repository.HTMLURL, p.PullRequest.Milestone.ID)
|
||||
}
|
||||
link = p.PullRequest.HTMLURL
|
||||
|
@ -62,11 +63,12 @@ func getIssuesInfo(p *api.IssuePayload) (issueTitle, link, by, operator, operate
|
|||
for i, user := range assignList {
|
||||
assignStringList[i] = user.UserName
|
||||
}
|
||||
if p.Action == api.HookIssueAssigned {
|
||||
switch p.Action {
|
||||
case api.HookIssueAssigned:
|
||||
operateResult = fmt.Sprintf("%s assign this to %s", p.Sender.UserName, assignList[len(assignList)-1].UserName)
|
||||
} else if p.Action == api.HookIssueUnassigned {
|
||||
case api.HookIssueUnassigned:
|
||||
operateResult = fmt.Sprintf("%s unassigned this for someone", p.Sender.UserName)
|
||||
} else if p.Action == api.HookIssueMilestoned {
|
||||
case api.HookIssueMilestoned:
|
||||
operateResult = fmt.Sprintf("%s/milestone/%d", p.Repository.HTMLURL, p.Issue.Milestone.ID)
|
||||
}
|
||||
link = p.Issue.HTMLURL
|
||||
|
|
|
@ -335,7 +335,7 @@ func TestMSTeamsPayload(t *testing.T) {
|
|||
assert.Equal(t, "[test/repo] New wiki page 'index' (Wiki change comment)", pl.Summary)
|
||||
assert.Len(t, pl.Sections, 1)
|
||||
assert.Equal(t, "user1", pl.Sections[0].ActivitySubtitle)
|
||||
assert.Equal(t, "", pl.Sections[0].Text)
|
||||
assert.Empty(t, pl.Sections[0].Text)
|
||||
assert.Len(t, pl.Sections[0].Facts, 2)
|
||||
for _, fact := range pl.Sections[0].Facts {
|
||||
if fact.Name == "Repository:" {
|
||||
|
@ -356,7 +356,7 @@ func TestMSTeamsPayload(t *testing.T) {
|
|||
assert.Equal(t, "[test/repo] Wiki page 'index' edited (Wiki change comment)", pl.Summary)
|
||||
assert.Len(t, pl.Sections, 1)
|
||||
assert.Equal(t, "user1", pl.Sections[0].ActivitySubtitle)
|
||||
assert.Equal(t, "", pl.Sections[0].Text)
|
||||
assert.Empty(t, pl.Sections[0].Text)
|
||||
assert.Len(t, pl.Sections[0].Facts, 2)
|
||||
for _, fact := range pl.Sections[0].Facts {
|
||||
if fact.Name == "Repository:" {
|
||||
|
|
|
@ -90,7 +90,7 @@ func TestSyncPushCommits(t *testing.T) {
|
|||
var payloadContent structs.PushPayload
|
||||
require.NoError(t, json.Unmarshal([]byte(hookTask.PayloadContent), &payloadContent))
|
||||
assert.Len(t, payloadContent.Commits, 1)
|
||||
assert.EqualValues(t, "2c54faec6c45d31c1abfaecdab471eac6633738a", payloadContent.Commits[0].ID)
|
||||
assert.Equal(t, "2c54faec6c45d31c1abfaecdab471eac6633738a", payloadContent.Commits[0].ID)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -129,6 +129,6 @@ func TestPushCommits(t *testing.T) {
|
|||
var payloadContent structs.PushPayload
|
||||
require.NoError(t, json.Unmarshal([]byte(hookTask.PayloadContent), &payloadContent))
|
||||
assert.Len(t, payloadContent.Commits, 1)
|
||||
assert.EqualValues(t, "2c54faec6c45d31c1abfaecdab471eac6633738a", payloadContent.Commits[0].ID)
|
||||
assert.Equal(t, "2c54faec6c45d31c1abfaecdab471eac6633738a", payloadContent.Commits[0].ID)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ func TestMain(m *testing.M) {
|
|||
|
||||
func TestWebPathSegments(t *testing.T) {
|
||||
a := WebPathSegments("a%2Fa/b+c/d-e/f-g.-")
|
||||
assert.EqualValues(t, []string{"a/a", "b c", "d e", "f-g"}, a)
|
||||
assert.Equal(t, []string{"a/a", "b c", "d e", "f-g"}, a)
|
||||
}
|
||||
|
||||
func TestUserTitleToWebPath(t *testing.T) {
|
||||
|
@ -63,7 +63,7 @@ func TestWebPathToDisplayName(t *testing.T) {
|
|||
{"a b", "a%20b.md"},
|
||||
} {
|
||||
_, displayName := WebPathToUserTitle(test.WebPath)
|
||||
assert.EqualValues(t, test.Expected, displayName)
|
||||
assert.Equal(t, test.Expected, displayName)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,7 +80,7 @@ func TestWebPathToGitPath(t *testing.T) {
|
|||
{"2000-01-02-meeting.md", "2000-01-02+meeting"},
|
||||
{"2000-01-02 meeting.-.md", "2000-01-02%20meeting.-"},
|
||||
} {
|
||||
assert.EqualValues(t, test.Expected, WebPathToGitPath(test.WikiName))
|
||||
assert.Equal(t, test.Expected, WebPathToGitPath(test.WikiName))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -134,9 +134,9 @@ func TestUserWebGitPathConsistency(t *testing.T) {
|
|||
_, userTitle1 := WebPathToUserTitle(webPath1)
|
||||
gitPath1 := WebPathToGitPath(webPath1)
|
||||
|
||||
assert.EqualValues(t, userTitle, userTitle1, "UserTitle for userTitle: %q", userTitle)
|
||||
assert.EqualValues(t, webPath, webPath1, "WebPath for userTitle: %q", userTitle)
|
||||
assert.EqualValues(t, gitPath, gitPath1, "GitPath for userTitle: %q", userTitle)
|
||||
assert.Equal(t, userTitle, userTitle1, "UserTitle for userTitle: %q", userTitle)
|
||||
assert.Equal(t, webPath, webPath1, "WebPath for userTitle: %q", userTitle)
|
||||
assert.Equal(t, gitPath, gitPath1, "GitPath for userTitle: %q", userTitle)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ func TestRepository_AddWikiPage(t *testing.T) {
|
|||
gitPath := WebPathToGitPath(webPath)
|
||||
entry, err := masterTree.GetTreeEntryByPath(gitPath)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, gitPath, entry.Name(), "%s not added correctly", userTitle)
|
||||
assert.Equal(t, gitPath, entry.Name(), "%s not added correctly", userTitle)
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ func TestRepository_EditWikiPage(t *testing.T) {
|
|||
gitPath := WebPathToGitPath(webPath)
|
||||
entry, err := masterTree.GetTreeEntryByPath(gitPath)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, gitPath, entry.Name(), "%s not edited correctly", newWikiName)
|
||||
assert.Equal(t, gitPath, entry.Name(), "%s not edited correctly", newWikiName)
|
||||
|
||||
if newWikiName != "Home" {
|
||||
_, err := masterTree.GetTreeEntryByPath("Home.md")
|
||||
|
@ -289,7 +289,7 @@ func TestPrepareWikiFileName(t *testing.T) {
|
|||
t.Errorf("expect to find an escaped file but we could not detect one")
|
||||
}
|
||||
}
|
||||
assert.EqualValues(t, tt.wikiPath, newWikiPath)
|
||||
assert.Equal(t, tt.wikiPath, newWikiPath)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -311,13 +311,13 @@ func TestPrepareWikiFileName_FirstPage(t *testing.T) {
|
|||
existence, newWikiPath, err := prepareGitPath(gitRepo, "master", "Home")
|
||||
assert.False(t, existence)
|
||||
require.NoError(t, err)
|
||||
assert.EqualValues(t, "Home.md", newWikiPath)
|
||||
assert.Equal(t, "Home.md", newWikiPath)
|
||||
}
|
||||
|
||||
func TestWebPathConversion(t *testing.T) {
|
||||
assert.Equal(t, "path/wiki", WebPathToURLPath(WebPath("path/wiki")))
|
||||
assert.Equal(t, "wiki", WebPathToURLPath(WebPath("wiki")))
|
||||
assert.Equal(t, "", WebPathToURLPath(WebPath("")))
|
||||
assert.Empty(t, WebPathToURLPath(WebPath("")))
|
||||
}
|
||||
|
||||
func TestWebPathFromRequest(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue