mirror of
https://codeberg.org/forgejo/forgejo.git
synced 2024-12-20 20:07:03 +01:00
Fix linting issues
This commit is contained in:
parent
674689af4a
commit
fe18428806
34 changed files with 64 additions and 69 deletions
|
@ -535,14 +535,14 @@ Forgejo or set your environment appropriately.`, "")
|
|||
|
||||
index := bytes.IndexByte(rs.Data, byte(0))
|
||||
if index >= len(rs.Data) {
|
||||
return fail(ctx, "Protocol: format error", "pkt-line: format error "+fmt.Sprint(rs.Data))
|
||||
return fail(ctx, "Protocol: format error", "pkt-line: format error %s", rs.Data)
|
||||
}
|
||||
|
||||
if index < 0 {
|
||||
if len(rs.Data) == 10 && rs.Data[9] == '\n' {
|
||||
index = 9
|
||||
} else {
|
||||
return fail(ctx, "Protocol: format error", "pkt-line: format error "+fmt.Sprint(rs.Data))
|
||||
return fail(ctx, "Protocol: format error", "pkt-line: format error %s", rs.Data)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -117,7 +117,7 @@ func TestDelayWriter(t *testing.T) {
|
|||
defer test.MockVariableValue(&setting.InternalToken, "Random")()
|
||||
defer test.MockVariableValue(&setting.InstallLock, true)()
|
||||
defer test.MockVariableValue(&setting.Git.VerbosePush, true)()
|
||||
require.NoError(t, os.Setenv("SSH_ORIGINAL_COMMAND", "true"))
|
||||
t.Setenv("SSH_ORIGINAL_COMMAND", "true")
|
||||
|
||||
// Setup the Stdin.
|
||||
f, err := os.OpenFile(t.TempDir()+"/stdin", os.O_RDWR|os.O_CREATE|os.O_EXCL, 0o666)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
package activities_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
@ -92,7 +91,7 @@ func TestGetUserHeatmapDataByUser(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
assert.Len(t, actions, contributions, "invalid action count: did the test data became too old?")
|
||||
assert.Equal(t, count, int64(contributions))
|
||||
assert.Equal(t, tc.CountResult, contributions, fmt.Sprintf("testcase '%s'", tc.desc))
|
||||
assert.Equal(t, tc.CountResult, contributions, tc.desc)
|
||||
|
||||
// Test JSON rendering
|
||||
jsonData, err := json.Marshal(heatmap)
|
||||
|
|
|
@ -114,7 +114,7 @@ func readArmoredSign(r io.Reader) (body io.Reader, err error) {
|
|||
return nil, err
|
||||
}
|
||||
if block.Type != openpgp.SignatureType {
|
||||
return nil, fmt.Errorf("expected '" + openpgp.SignatureType + "', got: " + block.Type)
|
||||
return nil, fmt.Errorf("expected %q, got: %s", openpgp.SignatureType, block.Type)
|
||||
}
|
||||
return block.Body, nil
|
||||
}
|
||||
|
@ -139,7 +139,7 @@ func tryGetKeyIDFromSignature(sig *packet.Signature) string {
|
|||
if sig.IssuerKeyId != nil && (*sig.IssuerKeyId) != 0 {
|
||||
return fmt.Sprintf("%016X", *sig.IssuerKeyId)
|
||||
}
|
||||
if sig.IssuerFingerprint != nil && len(sig.IssuerFingerprint) > 0 {
|
||||
if len(sig.IssuerFingerprint) > 0 {
|
||||
return fmt.Sprintf("%016X", sig.IssuerFingerprint[12:20])
|
||||
}
|
||||
return ""
|
||||
|
|
|
@ -22,7 +22,7 @@ func TestOAuth2Application_GenerateClientSecret(t *testing.T) {
|
|||
app := unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1})
|
||||
secret, err := app.GenerateClientSecret(db.DefaultContext)
|
||||
require.NoError(t, err)
|
||||
assert.Positive(t, len(secret))
|
||||
assert.NotEmpty(t, secret)
|
||||
unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: 1, ClientSecret: app.ClientSecret})
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
package git
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
|
@ -65,14 +64,6 @@ func TestBranchRuleMatch(t *testing.T) {
|
|||
|
||||
for _, kase := range kases {
|
||||
pb := ProtectedBranch{RuleName: kase.Rule}
|
||||
var should, infact string
|
||||
if !kase.ExpectedMatch {
|
||||
should = " not"
|
||||
} else {
|
||||
infact = " not"
|
||||
}
|
||||
assert.EqualValues(t, kase.ExpectedMatch, pb.Match(kase.BranchName),
|
||||
fmt.Sprintf("%s should%s match %s but it is%s", kase.BranchName, should, kase.Rule, infact),
|
||||
)
|
||||
assert.EqualValues(t, kase.ExpectedMatch, pb.Match(kase.BranchName), "%s - %s", kase.BranchName, kase.Rule)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ func UnwrapLDAPSourceCfg(x *xorm.Engine) error {
|
|||
if err != nil {
|
||||
return fmt.Errorf("failed to unmarshal %s: %w", source.Cfg, err)
|
||||
}
|
||||
if wrapped.Source != nil && len(wrapped.Source) > 0 {
|
||||
if len(wrapped.Source) > 0 {
|
||||
bs, err := json.Marshal(wrapped.Source)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
@ -57,8 +57,8 @@ func Test_AddRepoIDForAttachment(t *testing.T) {
|
|||
err := x.Table("attachment").Where("issue_id > 0").Find(&issueAttachments)
|
||||
require.NoError(t, err)
|
||||
for _, attach := range issueAttachments {
|
||||
assert.Greater(t, attach.RepoID, int64(0))
|
||||
assert.Greater(t, attach.IssueID, int64(0))
|
||||
assert.Positive(t, attach.RepoID)
|
||||
assert.Positive(t, attach.IssueID)
|
||||
var issue Issue
|
||||
has, err := x.ID(attach.IssueID).Get(&issue)
|
||||
require.NoError(t, err)
|
||||
|
@ -70,8 +70,8 @@ func Test_AddRepoIDForAttachment(t *testing.T) {
|
|||
err = x.Table("attachment").Where("release_id > 0").Find(&releaseAttachments)
|
||||
require.NoError(t, err)
|
||||
for _, attach := range releaseAttachments {
|
||||
assert.Greater(t, attach.RepoID, int64(0))
|
||||
assert.Greater(t, attach.ReleaseID, int64(0))
|
||||
assert.Positive(t, attach.RepoID)
|
||||
assert.Positive(t, attach.ReleaseID)
|
||||
var release Release
|
||||
has, err := x.ID(attach.ReleaseID).Get(&release)
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -743,7 +743,7 @@ func GetUserRepositories(ctx context.Context, opts *SearchRepoOptions) (Reposito
|
|||
cond = cond.And(builder.Eq{"is_private": false})
|
||||
}
|
||||
|
||||
if opts.LowerNames != nil && len(opts.LowerNames) > 0 {
|
||||
if len(opts.LowerNames) > 0 {
|
||||
cond = cond.And(builder.In("lower_name", opts.LowerNames))
|
||||
}
|
||||
|
||||
|
|
|
@ -598,7 +598,7 @@ func Test_ValidateUser(t *testing.T) {
|
|||
{ID: 2, Visibility: structs.VisibleTypePrivate}: true,
|
||||
}
|
||||
for kase, expected := range kases {
|
||||
assert.EqualValues(t, expected, nil == user_model.ValidateUser(kase), fmt.Sprintf("case: %+v", kase))
|
||||
assert.EqualValues(t, expected, nil == user_model.ValidateUser(kase))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
4
modules/cache/context.go
vendored
4
modules/cache/context.go
vendored
|
@ -73,7 +73,9 @@ func (cc *cacheContext) Expired() bool {
|
|||
return timeNow().Sub(cc.created) > cacheContextLifetime
|
||||
}
|
||||
|
||||
var cacheContextKey = struct{}{}
|
||||
type cacheContextType = struct{ useless struct{} }
|
||||
|
||||
var cacheContextKey = cacheContextType{useless: struct{}{}}
|
||||
|
||||
/*
|
||||
Since there are both WithCacheContext and WithNoCacheContext,
|
||||
|
|
|
@ -114,7 +114,7 @@ type LogNameStatusCommitData struct {
|
|||
// Next returns the next LogStatusCommitData
|
||||
func (g *LogNameStatusRepoParser) Next(treepath string, paths2ids map[string]int, changed []bool, maxpathlen int) (*LogNameStatusCommitData, error) {
|
||||
var err error
|
||||
if g.next == nil || len(g.next) == 0 {
|
||||
if len(g.next) == 0 {
|
||||
g.buffull = false
|
||||
g.next, err = g.rd.ReadSlice('\x00')
|
||||
if err != nil {
|
||||
|
|
|
@ -401,7 +401,7 @@ func (f *valuedField) Render() string {
|
|||
}
|
||||
|
||||
func (f *valuedField) Value() string {
|
||||
return strings.TrimSpace(f.Get(fmt.Sprintf("form-field-" + f.ID)))
|
||||
return strings.TrimSpace(f.Get("form-field-" + f.ID))
|
||||
}
|
||||
|
||||
func (f *valuedField) Options() []*valuedOption {
|
||||
|
|
|
@ -258,42 +258,42 @@ func ValidatePackageSpec(p *Package) error {
|
|||
}
|
||||
for _, cd := range p.VersionMetadata.CheckDepends {
|
||||
if !rePkgVer.MatchString(cd) {
|
||||
return util.NewInvalidArgumentErrorf("invalid check dependency: " + cd)
|
||||
return util.NewInvalidArgumentErrorf("invalid check dependency: %s", cd)
|
||||
}
|
||||
}
|
||||
for _, d := range p.VersionMetadata.Depends {
|
||||
if !rePkgVer.MatchString(d) {
|
||||
return util.NewInvalidArgumentErrorf("invalid dependency: " + d)
|
||||
return util.NewInvalidArgumentErrorf("invalid dependency: %s", d)
|
||||
}
|
||||
}
|
||||
for _, md := range p.VersionMetadata.MakeDepends {
|
||||
if !rePkgVer.MatchString(md) {
|
||||
return util.NewInvalidArgumentErrorf("invalid make dependency: " + md)
|
||||
return util.NewInvalidArgumentErrorf("invalid make dependency: %s", md)
|
||||
}
|
||||
}
|
||||
for _, p := range p.VersionMetadata.Provides {
|
||||
if !rePkgVer.MatchString(p) {
|
||||
return util.NewInvalidArgumentErrorf("invalid provides: " + p)
|
||||
return util.NewInvalidArgumentErrorf("invalid provides: %s", p)
|
||||
}
|
||||
}
|
||||
for _, p := range p.VersionMetadata.Conflicts {
|
||||
if !rePkgVer.MatchString(p) {
|
||||
return util.NewInvalidArgumentErrorf("invalid conflicts: " + p)
|
||||
return util.NewInvalidArgumentErrorf("invalid conflicts: %s", p)
|
||||
}
|
||||
}
|
||||
for _, p := range p.VersionMetadata.Replaces {
|
||||
if !rePkgVer.MatchString(p) {
|
||||
return util.NewInvalidArgumentErrorf("invalid replaces: " + p)
|
||||
return util.NewInvalidArgumentErrorf("invalid replaces: %s", p)
|
||||
}
|
||||
}
|
||||
for _, p := range p.VersionMetadata.Replaces {
|
||||
if !rePkgVer.MatchString(p) {
|
||||
return util.NewInvalidArgumentErrorf("invalid xdata: " + p)
|
||||
return util.NewInvalidArgumentErrorf("invalid xdata: %s", p)
|
||||
}
|
||||
}
|
||||
for _, od := range p.VersionMetadata.OptDepends {
|
||||
if !reOptDep.MatchString(od) {
|
||||
return util.NewInvalidArgumentErrorf("invalid optional dependency: " + od)
|
||||
return util.NewInvalidArgumentErrorf("invalid optional dependency: %s", od)
|
||||
}
|
||||
}
|
||||
for _, bf := range p.VersionMetadata.Backup {
|
||||
|
|
|
@ -120,7 +120,7 @@ func (q *baseChannel) RemoveAll(ctx context.Context) error {
|
|||
q.mu.Lock()
|
||||
defer q.mu.Unlock()
|
||||
|
||||
for q.c != nil && len(q.c) > 0 {
|
||||
for len(q.c) > 0 {
|
||||
<-q.c
|
||||
}
|
||||
|
||||
|
|
|
@ -173,8 +173,8 @@ func testWorkerPoolQueuePersistence(t *testing.T, queueSetting setting.QueueSett
|
|||
|
||||
q2() // restart the queue to continue to execute the tasks in it
|
||||
|
||||
assert.NotZero(t, len(tasksQ1))
|
||||
assert.NotZero(t, len(tasksQ2))
|
||||
assert.NotEmpty(t, tasksQ1)
|
||||
assert.NotEmpty(t, tasksQ2)
|
||||
assert.EqualValues(t, testCount, len(tasksQ1)+len(tasksQ2))
|
||||
}
|
||||
|
||||
|
|
|
@ -752,7 +752,7 @@ func EditPullRequest(ctx *context.APIContext) {
|
|||
// update allow edits
|
||||
if form.AllowMaintainerEdit != nil {
|
||||
if err := pull_service.SetAllowEdits(ctx, ctx.Doer, pr, *form.AllowMaintainerEdit); err != nil {
|
||||
if errors.Is(pull_service.ErrUserHasNoPermissionForAction, err) {
|
||||
if errors.Is(err, pull_service.ErrUserHasNoPermissionForAction) {
|
||||
ctx.Error(http.StatusForbidden, "SetAllowEdits", fmt.Sprintf("SetAllowEdits: %s", err))
|
||||
return
|
||||
}
|
||||
|
|
|
@ -1821,7 +1821,7 @@ func SetAllowEdits(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if err := pull_service.SetAllowEdits(ctx, ctx.Doer, pr, form.AllowMaintainerEdit); err != nil {
|
||||
if errors.Is(pull_service.ErrUserHasNoPermissionForAction, err) {
|
||||
if errors.Is(err, pull_service.ErrUserHasNoPermissionForAction) {
|
||||
ctx.Error(http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"bytes"
|
||||
gocontext "context"
|
||||
"encoding/base64"
|
||||
"errors"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"image"
|
||||
|
@ -753,12 +754,12 @@ func checkHomeCodeViewable(ctx *context.Context) {
|
|||
}
|
||||
|
||||
if firstUnit != nil {
|
||||
ctx.Redirect(fmt.Sprintf("%s%s", ctx.Repo.Repository.Link(), firstUnit.URI))
|
||||
ctx.Redirect(ctx.Repo.Repository.Link() + firstUnit.URI)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
ctx.NotFound("Home", fmt.Errorf(ctx.Locale.TrString("units.error.no_unit_allowed_repo")))
|
||||
ctx.NotFound("Home", errors.New(ctx.Locale.TrString("units.error.no_unit_allowed_repo")))
|
||||
}
|
||||
|
||||
func checkCitationFile(ctx *context.Context, entry *git.TreeEntry) {
|
||||
|
|
|
@ -761,7 +761,7 @@ func UsernameSubRoute(ctx *context.Context) {
|
|||
}
|
||||
// check view permissions
|
||||
if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) {
|
||||
ctx.NotFound("user", fmt.Errorf(ctx.ContextUser.Name))
|
||||
ctx.NotFound("User not visible", nil)
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
|
|
@ -56,7 +56,7 @@ func OwnerProfile(ctx *context.Context) {
|
|||
func userProfile(ctx *context.Context) {
|
||||
// check view permissions
|
||||
if !user_model.IsUserVisibleToViewer(ctx, ctx.ContextUser, ctx.Doer) {
|
||||
ctx.NotFound("user", fmt.Errorf(ctx.ContextUser.Name))
|
||||
ctx.NotFound("User not visible", nil)
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@ import (
|
|||
"github.com/nektos/act/pkg/model"
|
||||
)
|
||||
|
||||
var methodCtxKey struct{}
|
||||
type methodCtx struct{}
|
||||
|
||||
var methodCtxKey = methodCtx{}
|
||||
|
||||
// withMethod sets the notification method that this context currently executes.
|
||||
// Used for debugging/ troubleshooting purposes.
|
||||
|
|
|
@ -276,7 +276,7 @@ func handlePullRequestAutoMerge(pullID int64, sha string) {
|
|||
}
|
||||
|
||||
if err := pull_service.CheckPullMergeable(ctx, doer, &perm, pr, pull_service.MergeCheckTypeGeneral, false); err != nil {
|
||||
if errors.Is(pull_service.ErrUserNotAllowedToMerge, err) {
|
||||
if errors.Is(err, pull_service.ErrUserNotAllowedToMerge) {
|
||||
log.Info("%-v was scheduled to automerge by an unauthorized user", pr)
|
||||
return
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
package gitdiff
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
@ -645,9 +644,9 @@ func TestGetDiffRangeWithWhitespaceBehavior(t *testing.T) {
|
|||
MaxFiles: setting.Git.MaxGitDiffFiles,
|
||||
WhitespaceBehavior: behavior,
|
||||
})
|
||||
require.NoError(t, err, fmt.Sprintf("Error when diff with %s", behavior))
|
||||
require.NoError(t, err, "Error when diff with %s", behavior)
|
||||
for _, f := range diffs.Files {
|
||||
assert.Positive(t, len(f.Sections), fmt.Sprintf("%s should have sections", f.Name))
|
||||
assert.NotEmpty(t, f.Sections, "%s should have sections", f.Name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -289,7 +289,7 @@ func TestRelease_Update(t *testing.T) {
|
|||
IsTag: false,
|
||||
}
|
||||
require.NoError(t, CreateRelease(gitRepo, release, "", []*AttachmentChange{}))
|
||||
assert.Greater(t, release.ID, int64(0))
|
||||
assert.Positive(t, release.ID)
|
||||
|
||||
release.IsDraft = false
|
||||
tagName := release.TagName
|
||||
|
|
|
@ -40,7 +40,7 @@ func TestAPIListStopWatches(t *testing.T) {
|
|||
assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle)
|
||||
assert.EqualValues(t, repo.Name, apiWatches[0].RepoName)
|
||||
assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
|
||||
assert.Greater(t, apiWatches[0].Seconds, int64(0))
|
||||
assert.Positive(t, apiWatches[0].Seconds)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ package integration
|
|||
|
||||
import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
@ -52,15 +53,15 @@ func testAPIPushMirror(t *testing.T, u *url.URL) {
|
|||
remoteAddress := fmt.Sprintf("%s%s/%s", u.String(), url.PathEscape(user.Name), url.PathEscape(mirrorRepo.Name))
|
||||
|
||||
deletePushMirrors := repo_model.DeletePushMirrors
|
||||
deletePushMirrorsError := "deletePushMirrorsError"
|
||||
deletePushMirrorsError := errors.New("deletePushMirrorsError")
|
||||
deletePushMirrorsFail := func(ctx context.Context, opts repo_model.PushMirrorOptions) error {
|
||||
return fmt.Errorf(deletePushMirrorsError)
|
||||
return deletePushMirrorsError
|
||||
}
|
||||
|
||||
addPushMirrorRemote := mirror_service.AddPushMirrorRemote
|
||||
addPushMirrorRemoteError := "addPushMirrorRemoteError"
|
||||
addPushMirrorRemoteError := errors.New("addPushMirrorRemoteError")
|
||||
addPushMirrorRemoteFail := func(ctx context.Context, m *repo_model.PushMirror, addr string) error {
|
||||
return fmt.Errorf(addPushMirrorRemoteError)
|
||||
return addPushMirrorRemoteError
|
||||
}
|
||||
|
||||
for _, testCase := range []struct {
|
||||
|
@ -81,7 +82,7 @@ func testAPIPushMirror(t *testing.T, u *url.URL) {
|
|||
},
|
||||
{
|
||||
name: "fail to add and delete",
|
||||
message: deletePushMirrorsError,
|
||||
message: deletePushMirrorsError.Error(),
|
||||
status: http.StatusInternalServerError,
|
||||
mirrorCount: 1,
|
||||
setup: func() {
|
||||
|
@ -91,7 +92,7 @@ func testAPIPushMirror(t *testing.T, u *url.URL) {
|
|||
},
|
||||
{
|
||||
name: "fail to add",
|
||||
message: addPushMirrorRemoteError,
|
||||
message: addPushMirrorRemoteError.Error(),
|
||||
status: http.StatusInternalServerError,
|
||||
mirrorCount: 0,
|
||||
setup: func() {
|
||||
|
|
|
@ -266,17 +266,17 @@ func TestAPIDeleteReleaseByTagName(t *testing.T) {
|
|||
createNewReleaseUsingAPI(t, token, owner, repo, "release-tag", "", "Release Tag", "test")
|
||||
|
||||
// delete release
|
||||
req := NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name)).
|
||||
req := NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name).
|
||||
AddTokenAuth(token)
|
||||
_ = MakeRequest(t, req, http.StatusNoContent)
|
||||
|
||||
// make sure release is deleted
|
||||
req = NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name)).
|
||||
req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/releases/tags/release-tag", owner.Name, repo.Name).
|
||||
AddTokenAuth(token)
|
||||
_ = MakeRequest(t, req, http.StatusNotFound)
|
||||
|
||||
// delete release tag too
|
||||
req = NewRequestf(t, http.MethodDelete, fmt.Sprintf("/api/v1/repos/%s/%s/tags/release-tag", owner.Name, repo.Name)).
|
||||
req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/tags/release-tag", owner.Name, repo.Name).
|
||||
AddTokenAuth(token)
|
||||
_ = MakeRequest(t, req, http.StatusNoContent)
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ func TestAPIRepoTeams(t *testing.T) {
|
|||
if assert.Len(t, teams, 2) {
|
||||
assert.EqualValues(t, "Owners", teams[0].Name)
|
||||
assert.True(t, teams[0].CanCreateOrgRepo)
|
||||
assert.True(t, util.SliceSortedEqual(unit.AllUnitKeyNames(), teams[0].Units), fmt.Sprintf("%v == %v", unit.AllUnitKeyNames(), teams[0].Units))
|
||||
assert.True(t, util.SliceSortedEqual(unit.AllUnitKeyNames(), teams[0].Units))
|
||||
assert.EqualValues(t, "owner", teams[0].Permission)
|
||||
|
||||
assert.EqualValues(t, "test_team", teams[1].Name)
|
||||
|
|
|
@ -42,7 +42,7 @@ func (doc *HTMLDoc) AssertDropdown(t testing.TB, name string) *goquery.Selection
|
|||
t.Helper()
|
||||
|
||||
dropdownGroup := doc.Find(fmt.Sprintf(".dropdown:has(input[name='%s'])", name))
|
||||
assert.Equal(t, 1, dropdownGroup.Length(), fmt.Sprintf("%s dropdown does not exist", name))
|
||||
assert.Equal(t, 1, dropdownGroup.Length(), "%s dropdown does not exist", name)
|
||||
return dropdownGroup
|
||||
}
|
||||
|
||||
|
@ -60,13 +60,13 @@ func (doc *HTMLDoc) AssertDropdownHasSelectedOption(t testing.TB, dropdownName,
|
|||
dropdownGroup := doc.AssertDropdown(t, dropdownName)
|
||||
|
||||
selectedValue, _ := dropdownGroup.Find(fmt.Sprintf("input[name='%s']", dropdownName)).Attr("value")
|
||||
assert.Equal(t, expectedValue, selectedValue, fmt.Sprintf("%s dropdown doesn't have expected value selected", dropdownName))
|
||||
assert.Equal(t, expectedValue, selectedValue, "%s dropdown doesn't have expected value selected", dropdownName)
|
||||
|
||||
dropdownValues := dropdownGroup.Find(".menu [data-value]").Map(func(i int, s *goquery.Selection) string {
|
||||
value, _ := s.Attr("data-value")
|
||||
return value
|
||||
})
|
||||
assert.Contains(t, dropdownValues, expectedValue, fmt.Sprintf("%s dropdown doesn't have an option with expected value", dropdownName))
|
||||
assert.Contains(t, dropdownValues, expectedValue, "%s dropdown doesn't have an option with expected value", dropdownName)
|
||||
}
|
||||
|
||||
// Find gets the descendants of each element in the current set of
|
||||
|
|
|
@ -83,7 +83,7 @@ func TestMigrate(t *testing.T) {
|
|||
{svc: structs.ForgejoService},
|
||||
} {
|
||||
// Step 0: verify the repo is available
|
||||
req := NewRequestf(t, "GET", fmt.Sprintf("/%s/%s", ownerName, repoName))
|
||||
req := NewRequestf(t, "GET", "/%s/%s", ownerName, repoName)
|
||||
_ = session.MakeRequest(t, req, http.StatusOK)
|
||||
// Step 1: get the Gitea migration form
|
||||
req = NewRequestf(t, "GET", "/repo/migrate/?service_type=%d", s.svc)
|
||||
|
|
|
@ -45,7 +45,7 @@ func testRepoFork(t *testing.T, session *TestSession, ownerName, repoName, forkO
|
|||
link, exists := htmlDoc.doc.Find(fmt.Sprintf("form.ui.form[action=\"%s\"]", forkURL)).Attr("action")
|
||||
assert.True(t, exists, "The template has changed")
|
||||
_, exists = htmlDoc.doc.Find(fmt.Sprintf(".owner.dropdown .item[data-value=\"%d\"]", forkOwner.ID)).Attr("data-value")
|
||||
assert.True(t, exists, fmt.Sprintf("Fork owner '%s' is not present in select box", forkOwnerName))
|
||||
assert.True(t, exists, "Fork owner %q is not present in select box", forkOwnerName)
|
||||
req = NewRequestWithValues(t, "POST", link, map[string]string{
|
||||
"_csrf": htmlDoc.GetCSRF(),
|
||||
"uid": fmt.Sprintf("%d", forkOwner.ID),
|
||||
|
|
|
@ -444,7 +444,7 @@ func TestViewRepoDirectory(t *testing.T) {
|
|||
repoSummary := htmlDoc.doc.Find(".repository-summary")
|
||||
|
||||
repoFilesTable := htmlDoc.doc.Find("#repo-files-table")
|
||||
assert.NotZero(t, len(repoFilesTable.Nodes))
|
||||
assert.NotEmpty(t, repoFilesTable.Nodes)
|
||||
|
||||
assert.Zero(t, description.Length())
|
||||
assert.Zero(t, repoTopics.Length())
|
||||
|
|
|
@ -291,7 +291,7 @@ func TestListStopWatches(t *testing.T) {
|
|||
assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle)
|
||||
assert.EqualValues(t, repo.Name, apiWatches[0].RepoName)
|
||||
assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
|
||||
assert.Greater(t, apiWatches[0].Seconds, int64(0))
|
||||
assert.Positive(t, apiWatches[0].Seconds)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue