+142
-127
.golangci.yml
+142
-127
.golangci.yml
···
1
+
version: "2"
2
+
output:
3
+
sort-order:
4
+
- file
1
5
linters:
2
-
enable-all: false
3
-
disable-all: true
4
-
fast: false
6
+
default: none
5
7
enable:
6
8
- bidichk
7
9
- depguard
···
9
11
- errcheck
10
12
- forbidigo
11
13
- gocritic
12
-
- gofmt
13
-
- gofumpt
14
-
- gosimple
15
14
- govet
16
15
- ineffassign
17
16
- nakedret
18
17
- nolintlint
19
18
- revive
20
19
- staticcheck
21
-
- stylecheck
22
20
- testifylint
23
-
- typecheck
24
21
- unconvert
25
-
- unused
26
22
- unparam
23
+
- unused
27
24
- usetesting
28
25
- wastedassign
29
-
30
-
run:
31
-
timeout: 10m
32
-
33
-
output:
34
-
sort-results: true
35
-
sort-order: [file]
36
-
show-stats: true
37
-
38
-
linters-settings:
39
-
stylecheck:
40
-
checks: ["all", "-ST1005", "-ST1003"]
41
-
nakedret:
42
-
max-func-lines: 0
43
-
gocritic:
44
-
disabled-checks:
45
-
- ifElseChain
46
-
revive:
47
-
severity: error
26
+
settings:
27
+
depguard:
28
+
rules:
29
+
main:
30
+
deny:
31
+
- pkg: encoding/json
32
+
desc: use gitea's modules/json instead of encoding/json
33
+
- pkg: github.com/unknwon/com
34
+
desc: use gitea's util and replacements
35
+
- pkg: io/ioutil
36
+
desc: use os or io instead
37
+
- pkg: golang.org/x/exp
38
+
desc: it's experimental and unreliable
39
+
- pkg: forgejo.org/modules/git/internal
40
+
desc: do not use the internal package, use AddXxx function instead
41
+
- pkg: gopkg.in/ini.v1
42
+
desc: do not use the ini package, use gitea's config system instead
43
+
- pkg: github.com/minio/sha256-simd
44
+
desc: use crypto/sha256 instead, see https://codeberg.org/forgejo/forgejo/pulls/1528
45
+
gocritic:
46
+
disabled-checks:
47
+
- ifElseChain
48
+
revive:
49
+
severity: error
50
+
rules:
51
+
- name: atomic
52
+
- name: bare-return
53
+
- name: blank-imports
54
+
- name: constant-logical-expr
55
+
- name: context-as-argument
56
+
- name: context-keys-type
57
+
- name: dot-imports
58
+
- name: duplicated-imports
59
+
- name: empty-lines
60
+
- name: error-naming
61
+
- name: error-return
62
+
- name: error-strings
63
+
- name: errorf
64
+
- name: exported
65
+
- name: identical-branches
66
+
- name: if-return
67
+
- name: increment-decrement
68
+
- name: indent-error-flow
69
+
- name: modifies-value-receiver
70
+
- name: package-comments
71
+
- name: range
72
+
- name: receiver-naming
73
+
- name: redefines-builtin-id
74
+
- name: string-of-int
75
+
- name: superfluous-else
76
+
- name: time-naming
77
+
- name: unconditional-recursion
78
+
- name: unexported-return
79
+
- name: unreachable-code
80
+
- name: var-declaration
81
+
- name: var-naming
82
+
- name: redefines-builtin-id
83
+
disabled: true
84
+
staticcheck:
85
+
checks:
86
+
- all
87
+
testifylint:
88
+
disable:
89
+
- go-require
90
+
exclusions:
91
+
generated: lax
92
+
presets:
93
+
- comments
94
+
- common-false-positives
95
+
- legacy
96
+
- std-error-handling
48
97
rules:
49
-
- name: atomic
50
-
- name: bare-return
51
-
- name: blank-imports
52
-
- name: constant-logical-expr
53
-
- name: context-as-argument
54
-
- name: context-keys-type
55
-
- name: dot-imports
56
-
- name: duplicated-imports
57
-
- name: empty-lines
58
-
- name: error-naming
59
-
- name: error-return
60
-
- name: error-strings
61
-
- name: errorf
62
-
- name: exported
63
-
- name: identical-branches
64
-
- name: if-return
65
-
- name: increment-decrement
66
-
- name: indent-error-flow
67
-
- name: modifies-value-receiver
68
-
- name: package-comments
69
-
- name: range
70
-
- name: receiver-naming
71
-
- name: redefines-builtin-id
72
-
- name: string-of-int
73
-
- name: superfluous-else
74
-
- name: time-naming
75
-
- name: unconditional-recursion
76
-
- name: unexported-return
77
-
- name: unreachable-code
78
-
- name: var-declaration
79
-
- name: var-naming
80
-
- name: redefines-builtin-id
81
-
disabled: true
82
-
gofumpt:
83
-
extra-rules: true
84
-
depguard:
85
-
rules:
86
-
main:
87
-
deny:
88
-
- pkg: encoding/json
89
-
desc: use gitea's modules/json instead of encoding/json
90
-
- pkg: github.com/unknwon/com
91
-
desc: use gitea's util and replacements
92
-
- pkg: io/ioutil
93
-
desc: use os or io instead
94
-
- pkg: golang.org/x/exp
95
-
desc: it's experimental and unreliable
96
-
- pkg: forgejo.org/modules/git/internal
97
-
desc: do not use the internal package, use AddXxx function instead
98
-
- pkg: gopkg.in/ini.v1
99
-
desc: do not use the ini package, use gitea's config system instead
100
-
- pkg: github.com/minio/sha256-simd
101
-
desc: use crypto/sha256 instead, see https://codeberg.org/forgejo/forgejo/pulls/1528
102
-
testifylint:
103
-
disable:
104
-
- go-require
105
-
98
+
- linters:
99
+
- nolintlint
100
+
path: models/db/sql_postgres_with_schema.go
101
+
- linters:
102
+
- dupl
103
+
- errcheck
104
+
- gocyclo
105
+
- gosec
106
+
- staticcheck
107
+
- unparam
108
+
path: _test\.go
109
+
- linters:
110
+
- dupl
111
+
- errcheck
112
+
- gocyclo
113
+
- gosec
114
+
path: models/migrations/v
115
+
- linters:
116
+
- forbidigo
117
+
path: cmd
118
+
- linters:
119
+
- dupl
120
+
text: (?i)webhook
121
+
- linters:
122
+
- gocritic
123
+
text: (?i)`ID' should not be capitalized
124
+
- linters:
125
+
- deadcode
126
+
- unused
127
+
text: (?i)swagger
128
+
- linters:
129
+
- staticcheck
130
+
text: (?i)argument x is overwritten before first use
131
+
- linters:
132
+
- gocritic
133
+
text: '(?i)commentFormatting: put a space between `//` and comment text'
134
+
- linters:
135
+
- gocritic
136
+
text: '(?i)exitAfterDefer:'
137
+
- linters:
138
+
- staticcheck
139
+
text: "(ST1005|ST1003|QF1001):"
140
+
paths:
141
+
- node_modules
142
+
- public
143
+
- web_src
144
+
- third_party$
145
+
- builtin$
146
+
- examples$
106
147
issues:
107
148
max-issues-per-linter: 0
108
149
max-same-issues: 0
109
-
exclude-dirs: [node_modules, public, web_src]
110
-
exclude-case-sensitive: true
111
-
exclude-rules:
112
-
- path: models/db/sql_postgres_with_schema.go
113
-
linters:
114
-
- nolintlint
115
-
- path: _test\.go
116
-
linters:
117
-
- gocyclo
118
-
- errcheck
119
-
- dupl
120
-
- gosec
121
-
- unparam
122
-
- staticcheck
123
-
- path: models/migrations/v
124
-
linters:
125
-
- gocyclo
126
-
- errcheck
127
-
- dupl
128
-
- gosec
129
-
- path: cmd
130
-
linters:
131
-
- forbidigo
132
-
- text: "webhook"
133
-
linters:
134
-
- dupl
135
-
- text: "`ID' should not be capitalized"
136
-
linters:
137
-
- gocritic
138
-
- text: "swagger"
139
-
linters:
140
-
- unused
141
-
- deadcode
142
-
- text: "argument x is overwritten before first use"
143
-
linters:
144
-
- staticcheck
145
-
- text: "commentFormatting: put a space between `//` and comment text"
146
-
linters:
147
-
- gocritic
148
-
- text: "exitAfterDefer:"
149
-
linters:
150
-
- gocritic
150
+
formatters:
151
+
enable:
152
+
- gofmt
153
+
- gofumpt
154
+
settings:
155
+
gofumpt:
156
+
extra-rules: true
157
+
exclusions:
158
+
generated: lax
159
+
paths:
160
+
- node_modules
161
+
- public
162
+
- web_src
163
+
- third_party$
164
+
- builtin$
165
+
- examples$
+1
-1
Makefile
+1
-1
Makefile
···
39
39
AIR_PACKAGE ?= github.com/air-verse/air@v1 # renovate: datasource=go
40
40
EDITORCONFIG_CHECKER_PACKAGE ?= github.com/editorconfig-checker/editorconfig-checker/v3/cmd/editorconfig-checker@v3.2.1 # renovate: datasource=go
41
41
GOFUMPT_PACKAGE ?= mvdan.cc/gofumpt@v0.7.0 # renovate: datasource=go
42
-
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/cmd/golangci-lint@v1.64.7 # renovate: datasource=go
42
+
GOLANGCI_LINT_PACKAGE ?= github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.0.2 # renovate: datasource=go
43
43
GXZ_PACKAGE ?= github.com/ulikunitz/xz/cmd/gxz@v0.5.11 # renovate: datasource=go
44
44
MISSPELL_PACKAGE ?= github.com/golangci/misspell/cmd/misspell@v0.6.0 # renovate: datasource=go
45
45
SWAGGER_PACKAGE ?= github.com/go-swagger/go-swagger/cmd/swagger@v0.31.0 # renovate: datasource=go
+1
-1
build/lint-locale-usage/lint-locale-usage.go
+1
-1
build/lint-locale-usage/lint-locale-usage.go
+2
-2
build/lint-locale-usage/lint-locale-usage_test.go
+2
-2
build/lint-locale-usage/lint-locale-usage_test.go
···
37
37
38
38
func TestUsagesParser(t *testing.T) {
39
39
t.Run("go, simple", func(t *testing.T) {
40
-
assert.EqualValues(t,
40
+
assert.Equal(t,
41
41
[]string{"what.an.example"},
42
42
HandleGoFileWrapped(t, "<g1>", "package main\nfunc Render(ctx *context.Context) string { return ctx.Tr(\"what.an.example\"); }\n"))
43
43
})
44
44
45
45
t.Run("template, simple", func(t *testing.T) {
46
-
assert.EqualValues(t,
46
+
assert.Equal(t,
47
47
[]string{"what.an.example"},
48
48
HandleTemplateFileWrapped(t, "<t1>", "{{ ctx.Locale.Tr \"what.an.example\" }}\n"))
49
49
})
+20
-20
build/lint-locale/lint-locale_test.go
+20
-20
build/lint-locale/lint-locale_test.go
···
15
15
t.Run("Remove tags", func(t *testing.T) {
16
16
assert.Empty(t, checkLocaleContent([]byte(`hidden_comment_types_description = Comment types checked here will not be shown inside issue pages. Checking "Label" for example removes all "<user> added/removed <label>" comments.`)))
17
17
18
-
assert.EqualValues(t, []string{"key: \x1b[31m<not-an-allowed-key>\x1b[0m REPLACED-TAG"}, checkLocaleContent([]byte(`key = "<not-an-allowed-key> <label>"`)))
19
-
assert.EqualValues(t, []string{"key: \x1b[31m<user@example.com>\x1b[0m REPLACED-TAG"}, checkLocaleContent([]byte(`key = "<user@example.com> <email@example.com>"`)))
20
-
assert.EqualValues(t, []string{"key: \x1b[31m<tag>\x1b[0m REPLACED-TAG \x1b[31m</tag>\x1b[0m"}, checkLocaleContent([]byte(`key = "<tag> <email@example.com> </tag>"`)))
18
+
assert.Equal(t, []string{"key: \x1b[31m<not-an-allowed-key>\x1b[0m REPLACED-TAG"}, checkLocaleContent([]byte(`key = "<not-an-allowed-key> <label>"`)))
19
+
assert.Equal(t, []string{"key: \x1b[31m<user@example.com>\x1b[0m REPLACED-TAG"}, checkLocaleContent([]byte(`key = "<user@example.com> <email@example.com>"`)))
20
+
assert.Equal(t, []string{"key: \x1b[31m<tag>\x1b[0m REPLACED-TAG \x1b[31m</tag>\x1b[0m"}, checkLocaleContent([]byte(`key = "<tag> <email@example.com> </tag>"`)))
21
21
})
22
22
23
23
t.Run("Specific exception", func(t *testing.T) {
···
25
25
assert.Empty(t, checkLocaleContent([]byte(`pulls.title_desc_one = wants to merge %[1]d commit from <code>%[2]s</code> into <code id="%[4]s">%[3]s</code>`)))
26
26
assert.Empty(t, checkLocaleContent([]byte(`editor.commit_directly_to_this_branch = Commit directly to the <strong class="%[2]s">%[1]s</strong> branch.`)))
27
27
28
-
assert.EqualValues(t, []string{"workflow.dispatch.trigger_found: This workflow has a \x1b[31m<d>\x1b[0mworkflow_dispatch\x1b[31m</d>\x1b[0m event trigger."}, checkLocaleContent([]byte(`workflow.dispatch.trigger_found = This workflow has a <d>workflow_dispatch</d> event trigger.`)))
29
-
assert.EqualValues(t, []string{"key: <code\x1b[31m id=\"branch_targe\"\x1b[0m>%[3]s</code>"}, checkLocaleContent([]byte(`key = <code id="branch_targe">%[3]s</code>`)))
30
-
assert.EqualValues(t, []string{"key: <a\x1b[31m class=\"ui sh\"\x1b[0m href=\"https://TO-BE-REPLACED.COM\">"}, checkLocaleContent([]byte(`key = <a class="ui sh" href="%[3]s">`)))
31
-
assert.EqualValues(t, []string{"key: <a\x1b[31m class=\"js-click-me\"\x1b[0m href=\"https://TO-BE-REPLACED.COM\">"}, checkLocaleContent([]byte(`key = <a class="js-click-me" href="%[3]s">`)))
32
-
assert.EqualValues(t, []string{"key: <strong\x1b[31m class=\"branch-target\"\x1b[0m>%[1]s</strong>"}, checkLocaleContent([]byte(`key = <strong class="branch-target">%[1]s</strong>`)))
28
+
assert.Equal(t, []string{"workflow.dispatch.trigger_found: This workflow has a \x1b[31m<d>\x1b[0mworkflow_dispatch\x1b[31m</d>\x1b[0m event trigger."}, checkLocaleContent([]byte(`workflow.dispatch.trigger_found = This workflow has a <d>workflow_dispatch</d> event trigger.`)))
29
+
assert.Equal(t, []string{"key: <code\x1b[31m id=\"branch_targe\"\x1b[0m>%[3]s</code>"}, checkLocaleContent([]byte(`key = <code id="branch_targe">%[3]s</code>`)))
30
+
assert.Equal(t, []string{"key: <a\x1b[31m class=\"ui sh\"\x1b[0m href=\"https://TO-BE-REPLACED.COM\">"}, checkLocaleContent([]byte(`key = <a class="ui sh" href="%[3]s">`)))
31
+
assert.Equal(t, []string{"key: <a\x1b[31m class=\"js-click-me\"\x1b[0m href=\"https://TO-BE-REPLACED.COM\">"}, checkLocaleContent([]byte(`key = <a class="js-click-me" href="%[3]s">`)))
32
+
assert.Equal(t, []string{"key: <strong\x1b[31m class=\"branch-target\"\x1b[0m>%[1]s</strong>"}, checkLocaleContent([]byte(`key = <strong class="branch-target">%[1]s</strong>`)))
33
33
})
34
34
35
35
t.Run("General safe tags", func(t *testing.T) {
···
38
38
assert.Empty(t, checkLocaleContent([]byte("sqlite_helper = File path for the SQLite3 database.<br>Enter an absolute path if you run Forgejo as a service.")))
39
39
assert.Empty(t, checkLocaleContent([]byte("hi_user_x = Hi <b>%s</b>,")))
40
40
41
-
assert.EqualValues(t, []string{"error404: The page you are trying to reach either <strong\x1b[31m title='aaa'\x1b[0m>does not exist</strong> or <strong>you are not authorized</strong> to view it."}, checkLocaleContent([]byte("error404 = The page you are trying to reach either <strong title='aaa'>does not exist</strong> or <strong>you are not authorized</strong> to view it.")))
41
+
assert.Equal(t, []string{"error404: The page you are trying to reach either <strong\x1b[31m title='aaa'\x1b[0m>does not exist</strong> or <strong>you are not authorized</strong> to view it."}, checkLocaleContent([]byte("error404 = The page you are trying to reach either <strong title='aaa'>does not exist</strong> or <strong>you are not authorized</strong> to view it.")))
42
42
})
43
43
44
44
t.Run("<a>", func(t *testing.T) {
···
47
47
assert.Empty(t, checkLocaleContent([]byte(`webauthn_desc = Security keys are hardware devices containing cryptographic keys. They can be used for two-factor authentication. Security keys must support the <a rel="noreferrer" target="_blank" href="%s">WebAuthn Authenticator</a> standard.`)))
48
48
assert.Empty(t, checkLocaleContent([]byte("issues.closed_at = `closed this issue <a id=\"%[1]s\" href=\"#%[1]s\">%[2]s</a>`")))
49
49
50
-
assert.EqualValues(t, []string{"key: \x1b[31m<a href=\"https://example.com\">\x1b[0m"}, checkLocaleContent([]byte(`key = <a href="https://example.com">`)))
51
-
assert.EqualValues(t, []string{"key: \x1b[31m<a href=\"javascript:alert('1')\">\x1b[0m"}, checkLocaleContent([]byte(`key = <a href="javascript:alert('1')">`)))
52
-
assert.EqualValues(t, []string{"key: <a href=\"https://TO-BE-REPLACED.COM\"\x1b[31m download\x1b[0m>"}, checkLocaleContent([]byte(`key = <a href="%s" download>`)))
53
-
assert.EqualValues(t, []string{"key: <a href=\"https://TO-BE-REPLACED.COM\"\x1b[31m target=\"_self\"\x1b[0m>"}, checkLocaleContent([]byte(`key = <a href="%s" target="_self">`)))
54
-
assert.EqualValues(t, []string{"key: \x1b[31m<a href=\"https://example.com/%s\">\x1b[0m"}, checkLocaleContent([]byte(`key = <a href="https://example.com/%s">`)))
55
-
assert.EqualValues(t, []string{"key: \x1b[31m<a href=\"https://example.com/?q=%s\">\x1b[0m"}, checkLocaleContent([]byte(`key = <a href="https://example.com/?q=%s">`)))
56
-
assert.EqualValues(t, []string{"key: \x1b[31m<a href=\"%s/open-redirect\">\x1b[0m"}, checkLocaleContent([]byte(`key = <a href="%s/open-redirect">`)))
57
-
assert.EqualValues(t, []string{"key: \x1b[31m<a href=\"%s?q=open-redirect\">\x1b[0m"}, checkLocaleContent([]byte(`key = <a href="%s?q=open-redirect">`)))
50
+
assert.Equal(t, []string{"key: \x1b[31m<a href=\"https://example.com\">\x1b[0m"}, checkLocaleContent([]byte(`key = <a href="https://example.com">`)))
51
+
assert.Equal(t, []string{"key: \x1b[31m<a href=\"javascript:alert('1')\">\x1b[0m"}, checkLocaleContent([]byte(`key = <a href="javascript:alert('1')">`)))
52
+
assert.Equal(t, []string{"key: <a href=\"https://TO-BE-REPLACED.COM\"\x1b[31m download\x1b[0m>"}, checkLocaleContent([]byte(`key = <a href="%s" download>`)))
53
+
assert.Equal(t, []string{"key: <a href=\"https://TO-BE-REPLACED.COM\"\x1b[31m target=\"_self\"\x1b[0m>"}, checkLocaleContent([]byte(`key = <a href="%s" target="_self">`)))
54
+
assert.Equal(t, []string{"key: \x1b[31m<a href=\"https://example.com/%s\">\x1b[0m"}, checkLocaleContent([]byte(`key = <a href="https://example.com/%s">`)))
55
+
assert.Equal(t, []string{"key: \x1b[31m<a href=\"https://example.com/?q=%s\">\x1b[0m"}, checkLocaleContent([]byte(`key = <a href="https://example.com/?q=%s">`)))
56
+
assert.Equal(t, []string{"key: \x1b[31m<a href=\"%s/open-redirect\">\x1b[0m"}, checkLocaleContent([]byte(`key = <a href="%s/open-redirect">`)))
57
+
assert.Equal(t, []string{"key: \x1b[31m<a href=\"%s?q=open-redirect\">\x1b[0m"}, checkLocaleContent([]byte(`key = <a href="%s?q=open-redirect">`)))
58
58
})
59
59
60
60
t.Run("Escaped HTML characters", func(t *testing.T) {
61
61
assert.Empty(t, checkLocaleContent([]byte("activity.git_stats_push_to_branch = `إلى %s و\"`")))
62
62
63
-
assert.EqualValues(t, []string{"key: و\x1b[31m \x1b[0m\x1b[32m\u00a0\x1b[0m"}, checkLocaleContent([]byte(`key = و `)))
63
+
assert.Equal(t, []string{"key: و\x1b[31m \x1b[0m\x1b[32m\u00a0\x1b[0m"}, checkLocaleContent([]byte(`key = و `)))
64
64
})
65
65
}
66
66
···
75
75
}
76
76
}`)))
77
77
78
-
assert.EqualValues(t, []string{"settings.hidden_comment_types_description: \"\x1b[31m<not-an-allowed-key>\x1b[0m REPLACED-TAG\""}, checkLocaleNextContent([]byte(`{
78
+
assert.Equal(t, []string{"settings.hidden_comment_types_description: \"\x1b[31m<not-an-allowed-key>\x1b[0m REPLACED-TAG\""}, checkLocaleNextContent([]byte(`{
79
79
"settings": {
80
80
"hidden_comment_types_description": "\"<not-an-allowed-key> <label>\""
81
81
}
···
87
87
"settings.hidden_comment_types_description": "Comment types checked here will not be shown inside issue pages. Checking \"Label\" for example removes all \"<user> added/removed <label>\" comments."
88
88
}`)))
89
89
90
-
assert.EqualValues(t, []string{"settings.hidden_comment_types_description: \"\x1b[31m<not-an-allowed-key>\x1b[0m REPLACED-TAG\""}, checkLocaleNextContent([]byte(`{
90
+
assert.Equal(t, []string{"settings.hidden_comment_types_description: \"\x1b[31m<not-an-allowed-key>\x1b[0m REPLACED-TAG\""}, checkLocaleNextContent([]byte(`{
91
91
"settings.hidden_comment_types_description": "\"<not-an-allowed-key> <label>\""
92
92
}`)))
93
93
})
+6
-6
cmd/admin_auth_ldap_test.go
+6
-6
cmd/admin_auth_ldap_test.go
···
216
216
return nil
217
217
},
218
218
updateAuthSource: func(ctx context.Context, authSource *auth.Source) error {
219
-
assert.FailNow(t, "case %d: should not call updateAuthSource", n)
219
+
assert.FailNow(t, "should not call updateAuthSource", "case: %d", n)
220
220
return nil
221
221
},
222
222
getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) {
223
-
assert.FailNow(t, "case %d: should not call getAuthSourceByID", n)
223
+
assert.FailNow(t, "should not call getAuthSourceByID", "case: %d", n)
224
224
return nil, nil
225
225
},
226
226
}
···
447
447
return nil
448
448
},
449
449
updateAuthSource: func(ctx context.Context, authSource *auth.Source) error {
450
-
assert.FailNow(t, "case %d: should not call updateAuthSource", n)
450
+
assert.FailNow(t, "should not call updateAuthSource", "case: %d", n)
451
451
return nil
452
452
},
453
453
getAuthSourceByID: func(ctx context.Context, id int64) (*auth.Source, error) {
454
-
assert.FailNow(t, "case %d: should not call getAuthSourceByID", n)
454
+
assert.FailNow(t, "should not call getAuthSourceByID", "case: %d", n)
455
455
return nil, nil
456
456
},
457
457
}
···
898
898
return nil
899
899
},
900
900
createAuthSource: func(ctx context.Context, authSource *auth.Source) error {
901
-
assert.FailNow(t, "case %d: should not call createAuthSource", n)
901
+
assert.FailNow(t, "should not call createAuthSource", "case: %d", n)
902
902
return nil
903
903
},
904
904
updateAuthSource: func(ctx context.Context, authSource *auth.Source) error {
···
1288
1288
return nil
1289
1289
},
1290
1290
createAuthSource: func(ctx context.Context, authSource *auth.Source) error {
1291
-
assert.FailNow(t, "case %d: should not call createAuthSource", n)
1291
+
assert.FailNow(t, "should not call createAuthSource", "case: %d", n)
1292
1292
return nil
1293
1293
},
1294
1294
updateAuthSource: func(ctx context.Context, authSource *auth.Source) error {
+4
-3
cmd/doctor.go
+4
-3
cmd/doctor.go
···
143
143
setupConsoleLogger(log.FATAL, log.CanColorStderr, os.Stderr)
144
144
145
145
logFile := ctx.String("log-file")
146
-
if logFile == "" {
146
+
switch logFile {
147
+
case "":
147
148
return // if no doctor log-file is set, do not show any log from default logger
148
-
} else if logFile == "-" {
149
+
case "-":
149
150
setupConsoleLogger(log.TRACE, colorize, os.Stdout)
150
-
} else {
151
+
default:
151
152
logFile, _ = filepath.Abs(logFile)
152
153
writeMode := log.WriterMode{Level: log.TRACE, WriterOption: log.WriterFileOption{FileName: logFile}}
153
154
writer, err := log.NewEventWriter("console-to-file", "file", writeMode)
+1
-4
cmd/hook.go
+1
-4
cmd/hook.go
···
220
220
}
221
221
}
222
222
223
-
supportProcReceive := false
224
-
if git.CheckGitVersionAtLeast("2.29") == nil {
225
-
supportProcReceive = true
226
-
}
223
+
supportProcReceive := git.CheckGitVersionAtLeast("2.29") == nil
227
224
228
225
for scanner.Scan() {
229
226
// TODO: support news feeds for wiki
+3
-3
cmd/main.go
+3
-3
cmd/main.go
···
122
122
}
123
123
executable := filepath.Base(path)
124
124
125
-
var subCmdsStandalone []*cli.Command = make([]*cli.Command, 0, 10)
126
-
var subCmdWithConfig []*cli.Command = make([]*cli.Command, 0, 10)
127
-
var globalFlags []cli.Flag = make([]cli.Flag, 0, 10)
125
+
subCmdsStandalone := make([]*cli.Command, 0, 10)
126
+
subCmdWithConfig := make([]*cli.Command, 0, 10)
127
+
globalFlags := make([]cli.Flag, 0, 10)
128
128
129
129
//
130
130
// If the executable is forgejo-cli, provide a Forgejo specific CLI
+5
-5
cmd/main_test.go
+5
-5
cmd/main_test.go
···
132
132
r, err := runTestApp(app, "./gitea", "test-cmd")
133
133
require.Error(t, err)
134
134
assert.Equal(t, 1, r.ExitCode)
135
-
assert.Equal(t, "", r.Stdout)
135
+
assert.Empty(t, r.Stdout)
136
136
assert.Equal(t, "Command error: normal error\n", r.Stderr)
137
137
138
138
app = newTestApp(func(ctx *cli.Context) error { return cli.Exit("exit error", 2) })
139
139
r, err = runTestApp(app, "./gitea", "test-cmd")
140
140
require.Error(t, err)
141
141
assert.Equal(t, 2, r.ExitCode)
142
-
assert.Equal(t, "", r.Stdout)
142
+
assert.Empty(t, r.Stdout)
143
143
assert.Equal(t, "exit error\n", r.Stderr)
144
144
145
145
app = newTestApp(func(ctx *cli.Context) error { return nil })
···
147
147
require.Error(t, err)
148
148
assert.Equal(t, 1, r.ExitCode)
149
149
assert.Equal(t, "Incorrect Usage: flag provided but not defined: -no-such\n\n", r.Stdout)
150
-
assert.Equal(t, "", r.Stderr) // the cli package's strange behavior, the error message is not in stderr ....
150
+
assert.Empty(t, r.Stderr) // the cli package's strange behavior, the error message is not in stderr ....
151
151
152
152
app = newTestApp(func(ctx *cli.Context) error { return nil })
153
153
r, err = runTestApp(app, "./gitea", "test-cmd")
154
154
require.NoError(t, err)
155
155
assert.Equal(t, -1, r.ExitCode) // the cli.OsExiter is not called
156
-
assert.Equal(t, "", r.Stdout)
157
-
assert.Equal(t, "", r.Stderr)
156
+
assert.Empty(t, r.Stdout)
157
+
assert.Empty(t, r.Stderr)
158
158
}
+2
-2
cmd/migrate_storage_test.go
+2
-2
cmd/migrate_storage_test.go
···
81
81
entries, err := os.ReadDir(p)
82
82
require.NoError(t, err)
83
83
assert.Len(t, entries, 2)
84
-
assert.EqualValues(t, "01", entries[0].Name())
85
-
assert.EqualValues(t, "tmp", entries[1].Name())
84
+
assert.Equal(t, "01", entries[0].Name())
85
+
assert.Equal(t, "tmp", entries[1].Name())
86
86
}
87
87
88
88
func TestMigrateActionsArtifacts(t *testing.T) {
+4
-3
cmd/serv.go
+4
-3
cmd/serv.go
···
253
253
}
254
254
255
255
if verb == lfsAuthenticateVerb {
256
-
if lfsVerb == "upload" {
256
+
switch lfsVerb {
257
+
case "upload":
257
258
requestedMode = perm.AccessModeWrite
258
-
} else if lfsVerb == "download" {
259
+
case "download":
259
260
requestedMode = perm.AccessModeRead
260
-
} else {
261
+
default:
261
262
return fail(ctx, "Unknown LFS verb", "Unknown lfs verb %s", lfsVerb)
262
263
}
263
264
}
+42
-42
models/actions/forgejo_test.go
+42
-42
models/actions/forgejo_test.go
···
24
24
version := "v1.2.3"
25
25
runner, err := RegisterRunner(db.DefaultContext, ownerID, repoID, token, &labels, name, version)
26
26
require.NoError(t, err)
27
-
assert.EqualValues(t, name, runner.Name)
27
+
assert.Equal(t, name, runner.Name)
28
28
29
-
assert.EqualValues(t, 1, subtle.ConstantTimeCompare([]byte(runner.TokenHash), []byte(auth_model.HashToken(token, runner.TokenSalt))), "the token cannot be verified with the same method as routers/api/actions/runner/interceptor.go as of 8228751c55d6a4263f0fec2932ca16181c09c97d")
29
+
assert.Equal(t, 1, subtle.ConstantTimeCompare([]byte(runner.TokenHash), []byte(auth_model.HashToken(token, runner.TokenSalt))), "the token cannot be verified with the same method as routers/api/actions/runner/interceptor.go as of 8228751c55d6a4263f0fec2932ca16181c09c97d")
30
30
}
31
31
32
32
// TestActions_RegisterRunner_TokenUpdate tests that a token's secret is updated
···
73
73
require.NoError(t, err)
74
74
75
75
// Check that the returned record has been updated, except for the labels
76
-
assert.EqualValues(t, ownerID, runner.OwnerID)
77
-
assert.EqualValues(t, repoID, runner.RepoID)
78
-
assert.EqualValues(t, name, runner.Name)
79
-
assert.EqualValues(t, version, runner.Version)
80
-
assert.EqualValues(t, labelsCopy, runner.AgentLabels)
76
+
assert.Equal(t, ownerID, runner.OwnerID)
77
+
assert.Equal(t, repoID, runner.RepoID)
78
+
assert.Equal(t, name, runner.Name)
79
+
assert.Equal(t, version, runner.Version)
80
+
assert.Equal(t, labelsCopy, runner.AgentLabels)
81
81
82
82
// Check that whatever is in the DB has been updated, except for the labels
83
83
after := unittest.AssertExistsAndLoadBean(t, &ActionRunner{ID: runner.ID})
84
-
assert.EqualValues(t, ownerID, after.OwnerID)
85
-
assert.EqualValues(t, repoID, after.RepoID)
86
-
assert.EqualValues(t, name, after.Name)
87
-
assert.EqualValues(t, version, after.Version)
88
-
assert.EqualValues(t, labelsCopy, after.AgentLabels)
84
+
assert.Equal(t, ownerID, after.OwnerID)
85
+
assert.Equal(t, repoID, after.RepoID)
86
+
assert.Equal(t, name, after.Name)
87
+
assert.Equal(t, version, after.Version)
88
+
assert.Equal(t, labelsCopy, after.AgentLabels)
89
89
}
90
90
91
91
func TestActions_RegisterRunner_CreateWithoutLabels(t *testing.T) {
···
100
100
require.NoError(t, err)
101
101
102
102
// Check that the returned record has been updated, except for the labels
103
-
assert.EqualValues(t, ownerID, runner.OwnerID)
104
-
assert.EqualValues(t, repoID, runner.RepoID)
105
-
assert.EqualValues(t, name, runner.Name)
106
-
assert.EqualValues(t, version, runner.Version)
107
-
assert.EqualValues(t, []string{}, runner.AgentLabels)
103
+
assert.Equal(t, ownerID, runner.OwnerID)
104
+
assert.Equal(t, repoID, runner.RepoID)
105
+
assert.Equal(t, name, runner.Name)
106
+
assert.Equal(t, version, runner.Version)
107
+
assert.Equal(t, []string{}, runner.AgentLabels)
108
108
109
109
// Check that whatever is in the DB has been updated, except for the labels
110
110
after := unittest.AssertExistsAndLoadBean(t, &ActionRunner{ID: runner.ID})
111
-
assert.EqualValues(t, ownerID, after.OwnerID)
112
-
assert.EqualValues(t, repoID, after.RepoID)
113
-
assert.EqualValues(t, name, after.Name)
114
-
assert.EqualValues(t, version, after.Version)
115
-
assert.EqualValues(t, []string{}, after.AgentLabels)
111
+
assert.Equal(t, ownerID, after.OwnerID)
112
+
assert.Equal(t, repoID, after.RepoID)
113
+
assert.Equal(t, name, after.Name)
114
+
assert.Equal(t, version, after.Version)
115
+
assert.Equal(t, []string{}, after.AgentLabels)
116
116
}
117
117
118
118
func TestActions_RegisterRunner_UpdateWithLabels(t *testing.T) {
···
132
132
require.NoError(t, err)
133
133
134
134
// Check that the returned record has been updated
135
-
assert.EqualValues(t, newOwnerID, runner.OwnerID)
136
-
assert.EqualValues(t, newRepoID, runner.RepoID)
137
-
assert.EqualValues(t, newName, runner.Name)
138
-
assert.EqualValues(t, newVersion, runner.Version)
139
-
assert.EqualValues(t, labelsCopy, runner.AgentLabels)
135
+
assert.Equal(t, newOwnerID, runner.OwnerID)
136
+
assert.Equal(t, newRepoID, runner.RepoID)
137
+
assert.Equal(t, newName, runner.Name)
138
+
assert.Equal(t, newVersion, runner.Version)
139
+
assert.Equal(t, labelsCopy, runner.AgentLabels)
140
140
141
141
// Check that whatever is in the DB has been updated
142
142
after := unittest.AssertExistsAndLoadBean(t, &ActionRunner{ID: recordID})
143
-
assert.EqualValues(t, newOwnerID, after.OwnerID)
144
-
assert.EqualValues(t, newRepoID, after.RepoID)
145
-
assert.EqualValues(t, newName, after.Name)
146
-
assert.EqualValues(t, newVersion, after.Version)
147
-
assert.EqualValues(t, labelsCopy, after.AgentLabels)
143
+
assert.Equal(t, newOwnerID, after.OwnerID)
144
+
assert.Equal(t, newRepoID, after.RepoID)
145
+
assert.Equal(t, newName, after.Name)
146
+
assert.Equal(t, newVersion, after.Version)
147
+
assert.Equal(t, labelsCopy, after.AgentLabels)
148
148
}
149
149
150
150
func TestActions_RegisterRunner_UpdateWithoutLabels(t *testing.T) {
···
162
162
require.NoError(t, err)
163
163
164
164
// Check that the returned record has been updated, except for the labels
165
-
assert.EqualValues(t, newOwnerID, runner.OwnerID)
166
-
assert.EqualValues(t, newRepoID, runner.RepoID)
167
-
assert.EqualValues(t, newName, runner.Name)
168
-
assert.EqualValues(t, newVersion, runner.Version)
169
-
assert.EqualValues(t, before.AgentLabels, runner.AgentLabels)
165
+
assert.Equal(t, newOwnerID, runner.OwnerID)
166
+
assert.Equal(t, newRepoID, runner.RepoID)
167
+
assert.Equal(t, newName, runner.Name)
168
+
assert.Equal(t, newVersion, runner.Version)
169
+
assert.Equal(t, before.AgentLabels, runner.AgentLabels)
170
170
171
171
// Check that whatever is in the DB has been updated, except for the labels
172
172
after := unittest.AssertExistsAndLoadBean(t, &ActionRunner{ID: recordID})
173
-
assert.EqualValues(t, newOwnerID, after.OwnerID)
174
-
assert.EqualValues(t, newRepoID, after.RepoID)
175
-
assert.EqualValues(t, newName, after.Name)
176
-
assert.EqualValues(t, newVersion, after.Version)
177
-
assert.EqualValues(t, before.AgentLabels, after.AgentLabels)
173
+
assert.Equal(t, newOwnerID, after.OwnerID)
174
+
assert.Equal(t, newRepoID, after.RepoID)
175
+
assert.Equal(t, newName, after.Name)
176
+
assert.Equal(t, newVersion, after.Version)
177
+
assert.Equal(t, before.AgentLabels, after.AgentLabels)
178
178
}
+3
-2
models/actions/runner.go
+3
-2
models/actions/runner.go
···
87
87
return types.OwnerTypeRepository
88
88
}
89
89
if r.OwnerID != 0 {
90
-
if r.Owner.Type == user_model.UserTypeOrganization {
90
+
switch r.Owner.Type {
91
+
case user_model.UserTypeOrganization:
91
92
return types.OwnerTypeOrganization
92
-
} else if r.Owner.Type == user_model.UserTypeIndividual {
93
+
case user_model.UserTypeIndividual:
93
94
return types.OwnerTypeIndividual
94
95
}
95
96
}
+3
-3
models/actions/runner_token_test.go
+3
-3
models/actions/runner_token_test.go
···
18
18
token := unittest.AssertExistsAndLoadBean(t, &ActionRunnerToken{ID: 3})
19
19
expectedToken, err := GetLatestRunnerToken(db.DefaultContext, 1, 0)
20
20
require.NoError(t, err)
21
-
assert.EqualValues(t, expectedToken, token)
21
+
assert.Equal(t, expectedToken, token)
22
22
}
23
23
24
24
func TestNewRunnerToken(t *testing.T) {
···
27
27
require.NoError(t, err)
28
28
expectedToken, err := GetLatestRunnerToken(db.DefaultContext, 1, 0)
29
29
require.NoError(t, err)
30
-
assert.EqualValues(t, expectedToken, token)
30
+
assert.Equal(t, expectedToken, token)
31
31
}
32
32
33
33
func TestUpdateRunnerToken(t *testing.T) {
···
37
37
require.NoError(t, UpdateRunnerToken(db.DefaultContext, token))
38
38
expectedToken, err := GetLatestRunnerToken(db.DefaultContext, 1, 0)
39
39
require.NoError(t, err)
40
-
assert.EqualValues(t, expectedToken, token)
40
+
assert.Equal(t, expectedToken, token)
41
41
}
+3
-3
models/activities/action_test.go
+3
-3
models/activities/action_test.go
···
56
56
require.NoError(t, err)
57
57
if assert.Len(t, actions, 1) {
58
58
assert.EqualValues(t, 1, actions[0].ID)
59
-
assert.EqualValues(t, user.ID, actions[0].UserID)
59
+
assert.Equal(t, user.ID, actions[0].UserID)
60
60
}
61
61
assert.Equal(t, int64(1), count)
62
62
···
133
133
assert.Len(t, actions, 1)
134
134
if assert.Len(t, actions, 1) {
135
135
assert.EqualValues(t, 2, actions[0].ID)
136
-
assert.EqualValues(t, org.ID, actions[0].UserID)
136
+
assert.Equal(t, org.ID, actions[0].UserID)
137
137
}
138
138
assert.Equal(t, int64(1), count)
139
139
···
291
291
292
292
// load an issue
293
293
issue := unittest.AssertExistsAndLoadBean(t, &issue_model.Issue{ID: 4})
294
-
assert.NotEqualValues(t, issue.ID, issue.Index) // it needs to use different ID/Index to test the DeleteIssueActions to delete some actions by IssueIndex
294
+
assert.NotEqual(t, issue.ID, issue.Index) // it needs to use different ID/Index to test the DeleteIssueActions to delete some actions by IssueIndex
295
295
296
296
// insert a comment
297
297
err := db.Insert(db.DefaultContext, &issue_model.Comment{Type: issue_model.CommentTypeComment, IssueID: issue.ID})
+1
-1
models/activities/notification_list.go
+1
-1
models/activities/notification_list.go
···
107
107
return err
108
108
}
109
109
toNotify.AddMultiple(issueWatches...)
110
-
if !(issue.IsPull && issues_model.HasWorkInProgressPrefix(issue.Title)) {
110
+
if !issue.IsPull || !issues_model.HasWorkInProgressPrefix(issue.Title) {
111
111
repoWatches, err := repo_model.GetRepoWatchersIDs(ctx, issue.RepoID)
112
112
if err != nil {
113
113
return err
+6
-6
models/activities/notification_test.go
+6
-6
models/activities/notification_test.go
···
45
45
require.NoError(t, err)
46
46
if assert.Len(t, notfs, 3) {
47
47
assert.EqualValues(t, 5, notfs[0].ID)
48
-
assert.EqualValues(t, user.ID, notfs[0].UserID)
48
+
assert.Equal(t, user.ID, notfs[0].UserID)
49
49
assert.EqualValues(t, 4, notfs[1].ID)
50
-
assert.EqualValues(t, user.ID, notfs[1].UserID)
50
+
assert.Equal(t, user.ID, notfs[1].UserID)
51
51
assert.EqualValues(t, 2, notfs[2].ID)
52
-
assert.EqualValues(t, user.ID, notfs[2].UserID)
52
+
assert.Equal(t, user.ID, notfs[2].UserID)
53
53
}
54
54
}
55
55
···
59
59
repo, err := notf.GetRepo(db.DefaultContext)
60
60
require.NoError(t, err)
61
61
assert.Equal(t, repo, notf.Repository)
62
-
assert.EqualValues(t, notf.RepoID, repo.ID)
62
+
assert.Equal(t, notf.RepoID, repo.ID)
63
63
}
64
64
65
65
func TestNotification_GetIssue(t *testing.T) {
···
68
68
issue, err := notf.GetIssue(db.DefaultContext)
69
69
require.NoError(t, err)
70
70
assert.Equal(t, issue, notf.Issue)
71
-
assert.EqualValues(t, notf.IssueID, issue.ID)
71
+
assert.Equal(t, notf.IssueID, issue.ID)
72
72
}
73
73
74
74
func TestGetNotificationCount(t *testing.T) {
···
137
137
138
138
nt, err := activities_model.GetIssueNotification(db.DefaultContext, user.ID, issue.ID)
139
139
require.NoError(t, err)
140
-
assert.EqualValues(t, activities_model.NotificationStatusRead, nt.Status)
140
+
assert.Equal(t, activities_model.NotificationStatusRead, nt.Status)
141
141
}
+4
-4
models/activities/repo_activity_test.go
+4
-4
models/activities/repo_activity_test.go
···
23
23
stats, err := GetActivityStats(db.DefaultContext, repo, time.Unix(0, 0), true, true, true, true)
24
24
require.NoError(t, err)
25
25
26
-
assert.EqualValues(t, 2, stats.ActiveIssueCount())
27
-
assert.EqualValues(t, 2, stats.OpenedIssueCount())
28
-
assert.EqualValues(t, 0, stats.ClosedIssueCount())
29
-
assert.EqualValues(t, 3, stats.ActivePRCount())
26
+
assert.Equal(t, 2, stats.ActiveIssueCount())
27
+
assert.Equal(t, 2, stats.OpenedIssueCount())
28
+
assert.Equal(t, 0, stats.ClosedIssueCount())
29
+
assert.Equal(t, 3, stats.ActivePRCount())
30
30
}
+1
-1
models/asymkey/gpg_key_test.go
+1
-1
models/asymkey/gpg_key_test.go
···
293
293
require.NoError(t, err)
294
294
assert.Len(t, keys, 1)
295
295
assert.Len(t, keys[0].Emails, 1)
296
-
assert.EqualValues(t, "no-reply@golang.com", keys[0].Emails[0].Email)
296
+
assert.Equal(t, "no-reply@golang.com", keys[0].Emails[0].Email)
297
297
298
298
primaryKeyID := "D68172F48E9C5283"
299
299
// Assert primary key
+5
-5
models/asymkey/ssh_key_test.go
+5
-5
models/asymkey/ssh_key_test.go
···
44
44
keyTypeN, lengthN, err := SSHNativeParsePublicKey(tc.content)
45
45
require.NoError(t, err)
46
46
assert.Equal(t, tc.keyType, keyTypeN)
47
-
assert.EqualValues(t, tc.length, lengthN)
47
+
assert.Equal(t, tc.length, lengthN)
48
48
})
49
49
if tc.skipSSHKeygen {
50
50
return
···
54
54
if err != nil {
55
55
// Some servers do not support ecdsa format.
56
56
if !strings.Contains(err.Error(), "line 1 too long:") {
57
-
assert.FailNow(t, "%v", err)
57
+
require.NoError(t, err)
58
58
}
59
59
}
60
60
assert.Equal(t, tc.keyType, keyTypeK)
61
-
assert.EqualValues(t, tc.length, lengthK)
61
+
assert.Equal(t, tc.length, lengthK)
62
62
})
63
63
t.Run("SSHParseKeyNative", func(t *testing.T) {
64
64
keyTypeK, lengthK, err := SSHNativeParsePublicKey(tc.content)
65
65
if err != nil {
66
-
assert.FailNow(t, "%v", err)
66
+
require.NoError(t, err)
67
67
}
68
68
assert.Equal(t, tc.keyType, keyTypeK)
69
-
assert.EqualValues(t, tc.length, lengthK)
69
+
assert.Equal(t, tc.length, lengthK)
70
70
})
71
71
})
72
72
}
+2
-2
models/auth/oauth2_test.go
+2
-2
models/auth/oauth2_test.go
···
130
130
assert.NotNil(t, grant)
131
131
assert.Equal(t, int64(2), grant.UserID)
132
132
assert.Equal(t, int64(1), grant.ApplicationID)
133
-
assert.Equal(t, "", grant.Scope)
133
+
assert.Empty(t, grant.Scope)
134
134
}
135
135
136
136
//////////////////// Grant
···
271
271
func TestBuiltinApplicationsClientIDs(t *testing.T) {
272
272
clientIDs := auth_model.BuiltinApplicationsClientIDs()
273
273
slices.Sort(clientIDs)
274
-
assert.EqualValues(t, []string{"a4792ccc-144e-407e-86c9-5e7d8d9c3269", "d57cb8c4-630c-4168-8324-ec79935e18d4", "e90ee53c-94e2-48ac-9358-a874fb9e0662"}, clientIDs)
274
+
assert.Equal(t, []string{"a4792ccc-144e-407e-86c9-5e7d8d9c3269", "d57cb8c4-630c-4168-8324-ec79935e18d4", "e90ee53c-94e2-48ac-9358-a874fb9e0662"}, clientIDs)
275
275
}
276
276
277
277
func TestOrphanedOAuth2Applications(t *testing.T) {
+3
-3
models/auth/session_test.go
+3
-3
models/auth/session_test.go
···
37
37
// New session is created.
38
38
sess, err := auth.ReadSession(db.DefaultContext, key)
39
39
require.NoError(t, err)
40
-
assert.EqualValues(t, key, sess.Key)
40
+
assert.Equal(t, key, sess.Key)
41
41
assert.Empty(t, sess.Data)
42
42
assert.EqualValues(t, now.Unix(), sess.Expiry)
43
43
···
67
67
// Ensure data is updated and expiry is set from the update session call.
68
68
sess, err := auth.ReadSession(db.DefaultContext, key)
69
69
require.NoError(t, err)
70
-
assert.EqualValues(t, key, sess.Key)
71
-
assert.EqualValues(t, data, sess.Data)
70
+
assert.Equal(t, key, sess.Key)
71
+
assert.Equal(t, data, sess.Data)
72
72
assert.EqualValues(t, now.Unix(), sess.Expiry)
73
73
74
74
timeutil.MockSet(now)
+1
-1
models/db/engine_test.go
+1
-1
models/db/engine_test.go
+1
-1
models/db/list_test.go
+1
-1
models/db/list_test.go
+12
-12
models/dbfs/dbfs_test.go
+12
-12
models/dbfs/dbfs_test.go
···
32
32
33
33
n, err := f.Write([]byte("0123456789")) // blocks: 0123 4567 89
34
34
require.NoError(t, err)
35
-
assert.EqualValues(t, 10, n)
35
+
assert.Equal(t, 10, n)
36
36
37
37
_, err = f.Seek(0, io.SeekStart)
38
38
require.NoError(t, err)
39
39
40
40
buf, err := io.ReadAll(f)
41
41
require.NoError(t, err)
42
-
assert.EqualValues(t, 10, n)
43
-
assert.EqualValues(t, "0123456789", string(buf))
42
+
assert.Equal(t, 10, n)
43
+
assert.Equal(t, "0123456789", string(buf))
44
44
45
45
// write some new data
46
46
_, err = f.Seek(1, io.SeekStart)
···
51
51
// read from offset
52
52
buf, err = io.ReadAll(f)
53
53
require.NoError(t, err)
54
-
assert.EqualValues(t, "9", string(buf))
54
+
assert.Equal(t, "9", string(buf))
55
55
56
56
// read all
57
57
_, err = f.Seek(0, io.SeekStart)
58
58
require.NoError(t, err)
59
59
buf, err = io.ReadAll(f)
60
60
require.NoError(t, err)
61
-
assert.EqualValues(t, "0bcdefghi9", string(buf))
61
+
assert.Equal(t, "0bcdefghi9", string(buf))
62
62
63
63
// write to new size
64
64
_, err = f.Seek(-1, io.SeekEnd)
···
69
69
require.NoError(t, err)
70
70
buf, err = io.ReadAll(f)
71
71
require.NoError(t, err)
72
-
assert.EqualValues(t, "0bcdefghiJKLMNOP", string(buf))
72
+
assert.Equal(t, "0bcdefghiJKLMNOP", string(buf))
73
73
74
74
// write beyond EOF and fill with zero
75
75
_, err = f.Seek(5, io.SeekCurrent)
···
80
80
require.NoError(t, err)
81
81
buf, err = io.ReadAll(f)
82
82
require.NoError(t, err)
83
-
assert.EqualValues(t, "0bcdefghiJKLMNOP\x00\x00\x00\x00\x00xyzu", string(buf))
83
+
assert.Equal(t, "0bcdefghiJKLMNOP\x00\x00\x00\x00\x00xyzu", string(buf))
84
84
85
85
// write to the block with zeros
86
86
_, err = f.Seek(-6, io.SeekCurrent)
···
91
91
require.NoError(t, err)
92
92
buf, err = io.ReadAll(f)
93
93
require.NoError(t, err)
94
-
assert.EqualValues(t, "0bcdefghiJKLMNOP\x00\x00\x00ABCDzu", string(buf))
94
+
assert.Equal(t, "0bcdefghiJKLMNOP\x00\x00\x00ABCDzu", string(buf))
95
95
96
96
require.NoError(t, f.Close())
97
97
···
118
118
require.NoError(t, err)
119
119
stat, err := f.Stat()
120
120
require.NoError(t, err)
121
-
assert.EqualValues(t, "test.txt", stat.Name())
121
+
assert.Equal(t, "test.txt", stat.Name())
122
122
assert.EqualValues(t, 0, stat.Size())
123
123
_, err = f.Write([]byte("0123456789"))
124
124
require.NoError(t, err)
···
145
145
146
146
line, err := f2r.ReadString('\n')
147
147
require.NoError(t, err)
148
-
assert.EqualValues(t, "line 1\n", line)
148
+
assert.Equal(t, "line 1\n", line)
149
149
_, err = f2r.ReadString('\n')
150
150
require.ErrorIs(t, err, io.EOF)
151
151
···
154
154
155
155
line, err = f2r.ReadString('\n')
156
156
require.NoError(t, err)
157
-
assert.EqualValues(t, "line 2\n", line)
157
+
assert.Equal(t, "line 2\n", line)
158
158
_, err = f2r.ReadString('\n')
159
159
require.ErrorIs(t, err, io.EOF)
160
160
}
···
187
187
188
188
buf, err := io.ReadAll(fr)
189
189
require.NoError(t, err)
190
-
assert.EqualValues(t, "111333", string(buf))
190
+
assert.Equal(t, "111333", string(buf))
191
191
}
+3
-3
models/forgejo/semver/semver_test.go
+3
-3
models/forgejo/semver/semver_test.go
···
22
22
require.NoError(t, SetVersionString(ctx, newVersion.String()))
23
23
databaseVersion, err := GetVersion(ctx)
24
24
require.NoError(t, err)
25
-
assert.EqualValues(t, newVersion.String(), databaseVersion.String())
25
+
assert.Equal(t, newVersion.String(), databaseVersion.String())
26
26
assert.True(t, newVersion.Equal(databaseVersion))
27
27
}
28
28
···
36
36
37
37
v, err := GetVersion(ctx)
38
38
require.NoError(t, err)
39
-
assert.EqualValues(t, "1.0.0", v.String())
39
+
assert.Equal(t, "1.0.0", v.String())
40
40
41
41
_, err = e.Exec("drop table forgejo_sem_ver")
42
42
require.NoError(t, err)
43
43
44
44
v, err = GetVersion(ctx)
45
45
require.NoError(t, err)
46
-
assert.EqualValues(t, "1.0.0", v.String())
46
+
assert.Equal(t, "1.0.0", v.String())
47
47
}
+1
-1
models/forgejo_migrations/v1_22/v8_test.go
+1
-1
models/forgejo_migrations/v1_22/v8_test.go
+1
-1
models/git/branch_test.go
+1
-1
models/git/branch_test.go
···
22
22
func TestAddDeletedBranch(t *testing.T) {
23
23
require.NoError(t, unittest.PrepareTestDatabase())
24
24
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
25
-
assert.EqualValues(t, git.Sha1ObjectFormat.Name(), repo.ObjectFormatName)
25
+
assert.Equal(t, git.Sha1ObjectFormat.Name(), repo.ObjectFormatName)
26
26
firstBranch := unittest.AssertExistsAndLoadBean(t, &git_model.Branch{ID: 1})
27
27
28
28
assert.True(t, firstBranch.IsDeleted)
+5
-5
models/git/lfs_test.go
+5
-5
models/git/lfs_test.go
···
42
42
return nil
43
43
})
44
44
require.NoError(t, err)
45
-
assert.EqualValues(t, expected, cases)
45
+
assert.Equal(t, expected, cases)
46
46
})
47
47
48
48
t.Run("Low batch size", func(t *testing.T) {
···
54
54
return nil
55
55
})
56
56
require.NoError(t, err)
57
-
assert.EqualValues(t, expected, cases)
57
+
assert.Equal(t, expected, cases)
58
58
})
59
59
}
60
60
···
72
72
return nil
73
73
}, &IterateLFSMetaObjectsForRepoOptions{})
74
74
require.NoError(t, err)
75
-
assert.EqualValues(t, expectedIDs, actualIDs)
75
+
assert.Equal(t, expectedIDs, actualIDs)
76
76
})
77
77
78
78
t.Run("Low batch size", func(t *testing.T) {
···
84
84
return nil
85
85
}, &IterateLFSMetaObjectsForRepoOptions{})
86
86
require.NoError(t, err)
87
-
assert.EqualValues(t, expectedIDs, actualIDs)
87
+
assert.Equal(t, expectedIDs, actualIDs)
88
88
89
89
t.Run("Batch handles updates", func(t *testing.T) {
90
90
actualIDs := []int64{}
···
96
96
return nil
97
97
}, &IterateLFSMetaObjectsForRepoOptions{})
98
98
require.NoError(t, err)
99
-
assert.EqualValues(t, expectedIDs, actualIDs)
99
+
assert.Equal(t, expectedIDs, actualIDs)
100
100
})
101
101
})
102
102
}
+1
-1
models/git/protected_branch_list_test.go
+1
-1
models/git/protected_branch_list_test.go
···
71
71
require.Error(t, fmt.Errorf("no matched rules but expected %s[%d]", kase.Rules[kase.ExpectedMatchIdx], kase.ExpectedMatchIdx))
72
72
}
73
73
} else {
74
-
assert.EqualValues(t, kase.Rules[kase.ExpectedMatchIdx], matchedPB.RuleName)
74
+
assert.Equal(t, kase.Rules[kase.ExpectedMatchIdx], matchedPB.RuleName)
75
75
}
76
76
}
77
77
}
+1
-1
models/git/protected_branch_test.go
+1
-1
models/git/protected_branch_test.go
···
64
64
65
65
for _, kase := range kases {
66
66
pb := ProtectedBranch{RuleName: kase.Rule}
67
-
assert.EqualValues(t, kase.ExpectedMatch, pb.Match(kase.BranchName), "%s - %s", kase.BranchName, kase.Rule)
67
+
assert.Equal(t, kase.ExpectedMatch, pb.Match(kase.BranchName), "%s - %s", kase.BranchName, kase.Rule)
68
68
}
69
69
}
+6
-5
models/issues/action_aggregator.go
+6
-5
models/issues/action_aggregator.go
···
50
50
}
51
51
agg.EndInd = index
52
52
53
-
if c.Type == CommentTypeClose {
53
+
switch c.Type {
54
+
case CommentTypeClose:
54
55
agg.IsClosed = true
55
-
} else if c.Type == CommentTypeReopen {
56
+
case CommentTypeReopen:
56
57
agg.IsClosed = false
57
-
} else if c.Type == CommentTypeReviewRequest {
58
+
case CommentTypeReviewRequest:
58
59
if c.AssigneeID > 0 {
59
60
req := RequestReviewTarget{User: c.Assignee}
60
61
if c.RemovedAssignee {
···
78
79
for _, r := range c.AddedRequestReview {
79
80
agg.addReviewRequest(r)
80
81
}
81
-
} else if c.Type == CommentTypeLabel {
82
+
case CommentTypeLabel:
82
83
if c.Content == "1" {
83
84
agg.addLabel(c.Label)
84
85
} else {
85
86
agg.delLabel(c.Label)
86
87
}
87
-
} else if c.Type == CommentTypeAggregator {
88
+
case CommentTypeAggregator:
88
89
agg.Merge(c.Aggregator)
89
90
}
90
91
}
+6
-6
models/issues/comment_test.go
+6
-6
models/issues/comment_test.go
···
36
36
require.NoError(t, err)
37
37
then := time.Now().Unix()
38
38
39
-
assert.EqualValues(t, issues_model.CommentTypeComment, comment.Type)
40
-
assert.EqualValues(t, "Hello", comment.Content)
41
-
assert.EqualValues(t, issue.ID, comment.IssueID)
42
-
assert.EqualValues(t, doer.ID, comment.PosterID)
39
+
assert.Equal(t, issues_model.CommentTypeComment, comment.Type)
40
+
assert.Equal(t, "Hello", comment.Content)
41
+
assert.Equal(t, issue.ID, comment.IssueID)
42
+
assert.Equal(t, doer.ID, comment.PosterID)
43
43
unittest.AssertInt64InRange(t, now, then, int64(comment.CreatedUnix))
44
44
unittest.AssertExistsAndLoadBean(t, comment) // assert actually added to DB
45
45
···
95
95
require.NoError(t, err)
96
96
97
97
issueModified := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 1})
98
-
assert.EqualValues(t, issue.NumComments+1, issueModified.NumComments)
98
+
assert.Equal(t, issue.NumComments+1, issueModified.NumComments)
99
99
100
100
unittest.CheckConsistencyFor(t, &issues_model.Issue{})
101
101
}
···
132
132
133
133
require.NoError(t, issues_model.UpdateIssueNumComments(db.DefaultContext, issue2.ID))
134
134
issue2 = unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2})
135
-
assert.EqualValues(t, 1, issue2.NumComments)
135
+
assert.Equal(t, 1, issue2.NumComments)
136
136
}
+2
-2
models/issues/issue.go
+2
-2
models/issues/issue.go
···
646
646
err = sess.Find(&issueDeps)
647
647
648
648
for _, depInfo := range issueDeps {
649
-
depInfo.Issue.Repo = &depInfo.Repository
649
+
depInfo.Repo = &depInfo.Repository
650
650
}
651
651
652
652
return issueDeps, err
···
664
664
Find(&issueDeps)
665
665
666
666
for _, depInfo := range issueDeps {
667
-
depInfo.Issue.Repo = &depInfo.Repository
667
+
depInfo.Repo = &depInfo.Repository
668
668
}
669
669
670
670
return issueDeps, err
+9
-9
models/issues/issue_list_test.go
+9
-9
models/issues/issue_list_test.go
···
29
29
require.NoError(t, err)
30
30
assert.Len(t, repos, 2)
31
31
for _, issue := range issueList {
32
-
assert.EqualValues(t, issue.RepoID, issue.Repo.ID)
32
+
assert.Equal(t, issue.RepoID, issue.Repo.ID)
33
33
}
34
34
}
35
35
···
43
43
44
44
require.NoError(t, issueList.LoadAttributes(db.DefaultContext))
45
45
for _, issue := range issueList {
46
-
assert.EqualValues(t, issue.RepoID, issue.Repo.ID)
46
+
assert.Equal(t, issue.RepoID, issue.Repo.ID)
47
47
for _, label := range issue.Labels {
48
-
assert.EqualValues(t, issue.RepoID, label.RepoID)
48
+
assert.Equal(t, issue.RepoID, label.RepoID)
49
49
unittest.AssertExistsAndLoadBean(t, &issues_model.IssueLabel{IssueID: issue.ID, LabelID: label.ID})
50
50
}
51
51
if issue.PosterID > 0 {
52
-
assert.EqualValues(t, issue.PosterID, issue.Poster.ID)
52
+
assert.Equal(t, issue.PosterID, issue.Poster.ID)
53
53
}
54
54
if issue.AssigneeID > 0 {
55
-
assert.EqualValues(t, issue.AssigneeID, issue.Assignee.ID)
55
+
assert.Equal(t, issue.AssigneeID, issue.Assignee.ID)
56
56
}
57
57
if issue.MilestoneID > 0 {
58
-
assert.EqualValues(t, issue.MilestoneID, issue.Milestone.ID)
58
+
assert.Equal(t, issue.MilestoneID, issue.Milestone.ID)
59
59
}
60
60
if issue.IsPull {
61
-
assert.EqualValues(t, issue.ID, issue.PullRequest.IssueID)
61
+
assert.Equal(t, issue.ID, issue.PullRequest.IssueID)
62
62
}
63
63
for _, attachment := range issue.Attachments {
64
-
assert.EqualValues(t, issue.ID, attachment.IssueID)
64
+
assert.Equal(t, issue.ID, attachment.IssueID)
65
65
}
66
66
for _, comment := range issue.Comments {
67
-
assert.EqualValues(t, issue.ID, comment.IssueID)
67
+
assert.Equal(t, issue.ID, comment.IssueID)
68
68
}
69
69
if issue.ID == int64(1) {
70
70
assert.Equal(t, int64(400), issue.TotalTrackedTime)
+18
-18
models/issues/issue_project_test.go
+18
-18
models/issues/issue_project_test.go
···
39
39
40
40
issuesNum, err := issues.NumIssuesInProject(db.DefaultContext, orgProject, user2, org, optional.None[bool]())
41
41
require.NoError(t, err)
42
-
assert.EqualValues(t, 2, issuesNum)
42
+
assert.Equal(t, 2, issuesNum)
43
43
44
44
issuesNum, err = issues.NumIssuesInProject(db.DefaultContext, orgProject, user2, org, optional.Some(true))
45
45
require.NoError(t, err)
46
-
assert.EqualValues(t, 0, issuesNum)
46
+
assert.Equal(t, 0, issuesNum)
47
47
48
48
issuesNum, err = issues.NumIssuesInProject(db.DefaultContext, orgProject, user2, org, optional.Some(false))
49
49
require.NoError(t, err)
50
-
assert.EqualValues(t, 2, issuesNum)
50
+
assert.Equal(t, 2, issuesNum)
51
51
})
52
52
53
53
t.Run("Anonymous user", func(t *testing.T) {
···
59
59
60
60
issuesNum, err := issues.NumIssuesInProject(db.DefaultContext, orgProject, nil, org, optional.None[bool]())
61
61
require.NoError(t, err)
62
-
assert.EqualValues(t, 1, issuesNum)
62
+
assert.Equal(t, 1, issuesNum)
63
63
64
64
issuesNum, err = issues.NumIssuesInProject(db.DefaultContext, orgProject, nil, org, optional.Some(true))
65
65
require.NoError(t, err)
66
-
assert.EqualValues(t, 0, issuesNum)
66
+
assert.Equal(t, 0, issuesNum)
67
67
68
68
issuesNum, err = issues.NumIssuesInProject(db.DefaultContext, orgProject, nil, org, optional.Some(false))
69
69
require.NoError(t, err)
70
-
assert.EqualValues(t, 1, issuesNum)
70
+
assert.Equal(t, 1, issuesNum)
71
71
})
72
72
})
73
73
···
85
85
86
86
issuesNum, err := issues.NumIssuesInProject(db.DefaultContext, userProject, user2, nil, optional.None[bool]())
87
87
require.NoError(t, err)
88
-
assert.EqualValues(t, 2, issuesNum)
88
+
assert.Equal(t, 2, issuesNum)
89
89
90
90
issuesNum, err = issues.NumIssuesInProject(db.DefaultContext, userProject, user2, nil, optional.Some(true))
91
91
require.NoError(t, err)
92
-
assert.EqualValues(t, 0, issuesNum)
92
+
assert.Equal(t, 0, issuesNum)
93
93
94
94
issuesNum, err = issues.NumIssuesInProject(db.DefaultContext, userProject, user2, nil, optional.Some(false))
95
95
require.NoError(t, err)
96
-
assert.EqualValues(t, 2, issuesNum)
96
+
assert.Equal(t, 2, issuesNum)
97
97
})
98
98
99
99
t.Run("Anonymous user", func(t *testing.T) {
···
105
105
106
106
issuesNum, err := issues.NumIssuesInProject(db.DefaultContext, userProject, nil, nil, optional.None[bool]())
107
107
require.NoError(t, err)
108
-
assert.EqualValues(t, 1, issuesNum)
108
+
assert.Equal(t, 1, issuesNum)
109
109
110
110
issuesNum, err = issues.NumIssuesInProject(db.DefaultContext, userProject, nil, nil, optional.Some(true))
111
111
require.NoError(t, err)
112
-
assert.EqualValues(t, 0, issuesNum)
112
+
assert.Equal(t, 0, issuesNum)
113
113
114
114
issuesNum, err = issues.NumIssuesInProject(db.DefaultContext, userProject, nil, nil, optional.Some(false))
115
115
require.NoError(t, err)
116
-
assert.EqualValues(t, 1, issuesNum)
116
+
assert.Equal(t, 1, issuesNum)
117
117
})
118
118
})
119
119
}
···
137
137
138
138
issuesNum, err := issues.NumIssuesInProject(db.DefaultContext, orgProject, user29, org, optional.None[bool]())
139
139
require.NoError(t, err)
140
-
assert.EqualValues(t, 1, issuesNum)
140
+
assert.Equal(t, 1, issuesNum)
141
141
142
142
issuesNum, err = issues.NumIssuesInProject(db.DefaultContext, orgProject, user29, org, optional.Some(true))
143
143
require.NoError(t, err)
144
-
assert.EqualValues(t, 0, issuesNum)
144
+
assert.Equal(t, 0, issuesNum)
145
145
146
146
issuesNum, err = issues.NumIssuesInProject(db.DefaultContext, orgProject, user29, org, optional.Some(false))
147
147
require.NoError(t, err)
148
-
assert.EqualValues(t, 1, issuesNum)
148
+
assert.Equal(t, 1, issuesNum)
149
149
})
150
150
151
151
t.Run("Full access", func(t *testing.T) {
···
160
160
161
161
issuesNum, err := issues.NumIssuesInProject(db.DefaultContext, orgProject, user2, org, optional.None[bool]())
162
162
require.NoError(t, err)
163
-
assert.EqualValues(t, 2, issuesNum)
163
+
assert.Equal(t, 2, issuesNum)
164
164
165
165
issuesNum, err = issues.NumIssuesInProject(db.DefaultContext, orgProject, user2, org, optional.Some(true))
166
166
require.NoError(t, err)
167
-
assert.EqualValues(t, 0, issuesNum)
167
+
assert.Equal(t, 0, issuesNum)
168
168
169
169
issuesNum, err = issues.NumIssuesInProject(db.DefaultContext, orgProject, user2, org, optional.Some(false))
170
170
require.NoError(t, err)
171
-
assert.EqualValues(t, 2, issuesNum)
171
+
assert.Equal(t, 2, issuesNum)
172
172
})
173
173
}
+15
-15
models/issues/issue_test.go
+15
-15
models/issues/issue_test.go
···
143
143
then := time.Now().Unix()
144
144
145
145
updatedIssue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: issue.ID})
146
-
assert.EqualValues(t, newTitle, updatedIssue.Title)
147
-
assert.EqualValues(t, prevContent, updatedIssue.Content)
146
+
assert.Equal(t, newTitle, updatedIssue.Title)
147
+
assert.Equal(t, prevContent, updatedIssue.Content)
148
148
unittest.AssertInt64InRange(t, now, then, int64(updatedIssue.UpdatedUnix))
149
149
}
150
150
···
216
216
require.NoError(t, err)
217
217
if assert.Len(t, issues, len(test.ExpectedIssueIDs)) {
218
218
for i, issue := range issues {
219
-
assert.EqualValues(t, test.ExpectedIssueIDs[i], issue.ID)
219
+
assert.Equal(t, test.ExpectedIssueIDs[i], issue.ID)
220
220
}
221
221
}
222
222
}
···
249
249
has, err := db.GetEngine(db.DefaultContext).ID(issue.ID).Get(&newIssue)
250
250
require.NoError(t, err)
251
251
assert.True(t, has)
252
-
assert.EqualValues(t, issue.Title, newIssue.Title)
253
-
assert.EqualValues(t, issue.Content, newIssue.Content)
252
+
assert.Equal(t, issue.Title, newIssue.Title)
253
+
assert.Equal(t, issue.Content, newIssue.Content)
254
254
if expectIndex > 0 {
255
-
assert.EqualValues(t, expectIndex, newIssue.Index)
255
+
assert.Equal(t, expectIndex, newIssue.Index)
256
256
}
257
257
})
258
258
return &newIssue
···
286
286
ids[i] = user.ID
287
287
}
288
288
sort.Slice(ids, func(i, j int) bool { return ids[i] < ids[j] })
289
-
assert.EqualValues(t, expected, ids)
289
+
assert.Equal(t, expected, ids)
290
290
}
291
291
292
292
// Public repo, existing user
···
421
421
422
422
for _, issue := range issueList {
423
423
require.NoError(t, issue.LoadAttributes(db.DefaultContext))
424
-
assert.EqualValues(t, issue.RepoID, issue.Repo.ID)
424
+
assert.Equal(t, issue.RepoID, issue.Repo.ID)
425
425
for _, label := range issue.Labels {
426
-
assert.EqualValues(t, issue.RepoID, label.RepoID)
426
+
assert.Equal(t, issue.RepoID, label.RepoID)
427
427
unittest.AssertExistsAndLoadBean(t, &issues_model.IssueLabel{IssueID: issue.ID, LabelID: label.ID})
428
428
}
429
429
if issue.PosterID > 0 {
430
-
assert.EqualValues(t, issue.PosterID, issue.Poster.ID)
430
+
assert.Equal(t, issue.PosterID, issue.Poster.ID)
431
431
}
432
432
if issue.AssigneeID > 0 {
433
-
assert.EqualValues(t, issue.AssigneeID, issue.Assignee.ID)
433
+
assert.Equal(t, issue.AssigneeID, issue.Assignee.ID)
434
434
}
435
435
if issue.MilestoneID > 0 {
436
-
assert.EqualValues(t, issue.MilestoneID, issue.Milestone.ID)
436
+
assert.Equal(t, issue.MilestoneID, issue.Milestone.ID)
437
437
}
438
438
if issue.IsPull {
439
-
assert.EqualValues(t, issue.ID, issue.PullRequest.IssueID)
439
+
assert.Equal(t, issue.ID, issue.PullRequest.IssueID)
440
440
}
441
441
for _, attachment := range issue.Attachments {
442
-
assert.EqualValues(t, issue.ID, attachment.IssueID)
442
+
assert.Equal(t, issue.ID, attachment.IssueID)
443
443
}
444
444
for _, comment := range issue.Comments {
445
-
assert.EqualValues(t, issue.ID, comment.IssueID)
445
+
assert.Equal(t, issue.ID, comment.IssueID)
446
446
}
447
447
if issue.ID == int64(1) {
448
448
assert.Equal(t, int64(400), issue.TotalTrackedTime)
+14
-14
models/issues/label_test.go
+14
-14
models/issues/label_test.go
···
21
21
require.NoError(t, unittest.PrepareTestDatabase())
22
22
label := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 1})
23
23
label.CalOpenIssues()
24
-
assert.EqualValues(t, 2, label.NumOpenIssues)
24
+
assert.Equal(t, 2, label.NumOpenIssues)
25
25
}
26
26
27
27
func TestLabel_LoadSelectedLabelsAfterClick(t *testing.T) {
···
156
156
require.NoError(t, err)
157
157
assert.Len(t, labels, len(expectedIssueIDs))
158
158
for i, label := range labels {
159
-
assert.EqualValues(t, expectedIssueIDs[i], label.ID)
159
+
assert.Equal(t, expectedIssueIDs[i], label.ID)
160
160
}
161
161
}
162
162
testSuccess(1, "leastissues", []int64{2, 1})
···
223
223
require.NoError(t, err)
224
224
assert.Len(t, labels, len(expectedIssueIDs))
225
225
for i, label := range labels {
226
-
assert.EqualValues(t, expectedIssueIDs[i], label.ID)
226
+
assert.Equal(t, expectedIssueIDs[i], label.ID)
227
227
}
228
228
}
229
229
testSuccess(3, "leastissues", []int64{3, 4})
···
269
269
label.Name = update.Name
270
270
require.NoError(t, issues_model.UpdateLabel(db.DefaultContext, update))
271
271
newLabel := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 1})
272
-
assert.EqualValues(t, label.ID, newLabel.ID)
273
-
assert.EqualValues(t, label.Color, newLabel.Color)
274
-
assert.EqualValues(t, label.Name, newLabel.Name)
275
-
assert.EqualValues(t, label.Description, newLabel.Description)
272
+
assert.Equal(t, label.ID, newLabel.ID)
273
+
assert.Equal(t, label.Color, newLabel.Color)
274
+
assert.Equal(t, label.Name, newLabel.Name)
275
+
assert.Equal(t, label.Description, newLabel.Description)
276
276
assert.EqualValues(t, 0, newLabel.ArchivedUnix)
277
277
unittest.CheckConsistencyFor(t, &issues_model.Label{}, &repo_model.Repository{})
278
278
}
···
315
315
Content: "1",
316
316
})
317
317
label = unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 2})
318
-
assert.EqualValues(t, prevNumIssues+1, label.NumIssues)
318
+
assert.Equal(t, prevNumIssues+1, label.NumIssues)
319
319
320
320
// re-add existing IssueLabel
321
321
require.NoError(t, issues_model.NewIssueLabel(db.DefaultContext, issue, label, doer))
···
368
368
})
369
369
unittest.AssertExistsAndLoadBean(t, &issues_model.IssueLabel{IssueID: issue.ID, LabelID: label1.ID})
370
370
label1 = unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 1})
371
-
assert.EqualValues(t, 3, label1.NumIssues)
372
-
assert.EqualValues(t, 1, label1.NumClosedIssues)
371
+
assert.Equal(t, 3, label1.NumIssues)
372
+
assert.Equal(t, 1, label1.NumClosedIssues)
373
373
label2 = unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: 2})
374
-
assert.EqualValues(t, 1, label2.NumIssues)
375
-
assert.EqualValues(t, 1, label2.NumClosedIssues)
374
+
assert.Equal(t, 1, label2.NumIssues)
375
+
assert.Equal(t, 1, label2.NumClosedIssues)
376
376
377
377
// corner case: test empty slice
378
378
require.NoError(t, issues_model.NewIssueLabels(db.DefaultContext, issue, []*issues_model.Label{}, doer))
···
410
410
LabelID: labelID,
411
411
}, `content=""`)
412
412
label = unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: labelID})
413
-
assert.EqualValues(t, expectedNumIssues, label.NumIssues)
414
-
assert.EqualValues(t, expectedNumClosedIssues, label.NumClosedIssues)
413
+
assert.Equal(t, expectedNumIssues, label.NumIssues)
414
+
assert.Equal(t, expectedNumClosedIssues, label.NumClosedIssues)
415
415
}
416
416
testSuccess(1, 1, 2)
417
417
testSuccess(2, 5, 2)
+3
-3
models/issues/milestone_test.go
+3
-3
models/issues/milestone_test.go
···
70
70
71
71
assert.Len(t, milestones, n)
72
72
for _, milestone := range milestones {
73
-
assert.EqualValues(t, repoID, milestone.RepoID)
73
+
assert.Equal(t, repoID, milestone.RepoID)
74
74
}
75
75
}
76
76
test(1, api.StateOpen)
···
327
327
milestone.Content = "newMilestoneContent"
328
328
require.NoError(t, issues_model.UpdateMilestone(db.DefaultContext, milestone, milestone.IsClosed))
329
329
milestone = unittest.AssertExistsAndLoadBean(t, &issues_model.Milestone{ID: 1})
330
-
assert.EqualValues(t, "newMilestoneName", milestone.Name)
330
+
assert.Equal(t, "newMilestoneName", milestone.Name)
331
331
unittest.CheckConsistencyFor(t, &issues_model.Milestone{})
332
332
}
333
333
···
364
364
require.NoError(t, err)
365
365
unittest.AssertExistsAndLoadBean(t, ms)
366
366
repoModified := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: repo.ID})
367
-
assert.EqualValues(t, repo.NumMilestones+1, repoModified.NumMilestones)
367
+
assert.Equal(t, repo.NumMilestones+1, repoModified.NumMilestones)
368
368
369
369
unittest.CheckConsistencyFor(t, &issues_model.Milestone{})
370
370
}
+2
-2
models/issues/pull_test.go
+2
-2
models/issues/pull_test.go
···
399
399
400
400
countAfter, err := db.GetEngine(db.DefaultContext).Count(&issues_model.PullRequest{})
401
401
require.NoError(t, err)
402
-
assert.EqualValues(t, countBefore, countAfter)
402
+
assert.Equal(t, countBefore, countAfter)
403
403
}
404
404
405
405
func TestParseCodeOwnersLine(t *testing.T) {
···
432
432
setting.Repository.PullRequest.DefaultMergeMessageOfficialApproversOnly = false
433
433
approvers := pr.GetApprovers(db.DefaultContext)
434
434
expected := "Reviewed-by: User Five <user5@example.com>\nReviewed-by: Org Six <org6@example.com>\n"
435
-
assert.EqualValues(t, expected, approvers)
435
+
assert.Equal(t, expected, approvers)
436
436
}
437
437
438
438
func TestGetPullRequestByMergedCommit(t *testing.T) {
+1
-1
models/issues/stopwatch_test.go
+1
-1
models/issues/stopwatch_test.go
+3
-3
models/migrations/migrations_test.go
+3
-3
models/migrations/migrations_test.go
···
21
21
22
22
assert.EqualValues(t, 71, migrationIDNumberToDBVersion(70))
23
23
24
-
assert.EqualValues(t, []*migration{{idNumber: 70}, {idNumber: 71}}, getPendingMigrations(70, preparedMigrations))
25
-
assert.EqualValues(t, []*migration{{idNumber: 71}}, getPendingMigrations(71, preparedMigrations))
26
-
assert.EqualValues(t, []*migration{}, getPendingMigrations(72, preparedMigrations))
24
+
assert.Equal(t, []*migration{{idNumber: 70}, {idNumber: 71}}, getPendingMigrations(70, preparedMigrations))
25
+
assert.Equal(t, []*migration{{idNumber: 71}}, getPendingMigrations(71, preparedMigrations))
26
+
assert.Equal(t, []*migration{}, getPendingMigrations(72, preparedMigrations))
27
27
}
+2
-2
models/migrations/v1_15/v181_test.go
+2
-2
models/migrations/v1_15/v181_test.go
···
50
50
require.NoError(t, err)
51
51
assert.True(t, has)
52
52
assert.True(t, emailAddress.IsPrimary)
53
-
assert.EqualValues(t, user.IsActive, emailAddress.IsActivated)
54
-
assert.EqualValues(t, user.ID, emailAddress.UID)
53
+
assert.Equal(t, user.IsActive, emailAddress.IsActivated)
54
+
assert.Equal(t, user.ID, emailAddress.UID)
55
55
}
56
56
}
+2
-2
models/migrations/v1_16/v189_test.go
+2
-2
models/migrations/v1_16/v189_test.go
···
76
76
return
77
77
}
78
78
79
-
assert.EqualValues(t, expected, converted, "UnwrapLDAPSourceCfg failed for %d", source.ID)
80
-
assert.EqualValues(t, source.ID%2 == 0, source.IsActive, "UnwrapLDAPSourceCfg failed for %d", source.ID)
79
+
assert.Equal(t, expected, converted, "UnwrapLDAPSourceCfg failed for %d", source.ID)
80
+
assert.Equal(t, source.ID%2 == 0, source.IsActive, "UnwrapLDAPSourceCfg failed for %d", source.ID)
81
81
}
82
82
}
83
83
}
+2
-2
models/migrations/v1_16/v193_test.go
+2
-2
models/migrations/v1_16/v193_test.go
···
63
63
has, err := x.ID(attach.IssueID).Get(&issue)
64
64
require.NoError(t, err)
65
65
assert.True(t, has)
66
-
assert.EqualValues(t, attach.RepoID, issue.RepoID)
66
+
assert.Equal(t, attach.RepoID, issue.RepoID)
67
67
}
68
68
69
69
var releaseAttachments []*NewAttachment
···
76
76
has, err := x.ID(attach.ReleaseID).Get(&release)
77
77
require.NoError(t, err)
78
78
assert.True(t, has)
79
-
assert.EqualValues(t, attach.RepoID, release.RepoID)
79
+
assert.Equal(t, attach.RepoID, release.RepoID)
80
80
}
81
81
}
+1
-1
models/migrations/v1_16/v210_test.go
+1
-1
models/migrations/v1_16/v210_test.go
+1
-1
models/migrations/v1_19/v233_test.go
+1
-1
models/migrations/v1_19/v233_test.go
···
63
63
assert.Equal(t, e.Meta, got[i].Meta)
64
64
65
65
if e.HeaderAuthorization == "" {
66
-
assert.Equal(t, "", got[i].HeaderAuthorizationEncrypted)
66
+
assert.Empty(t, got[i].HeaderAuthorizationEncrypted)
67
67
} else {
68
68
cipherhex := got[i].HeaderAuthorizationEncrypted
69
69
cleartext, err := secret.DecryptSecret(setting.SecretKey, cipherhex)
+1
-1
models/migrations/v1_20/v259_test.go
+1
-1
models/migrations/v1_20/v259_test.go
···
97
97
tokens := make([]AccessToken, 0)
98
98
err = x.Find(&tokens)
99
99
require.NoError(t, err)
100
-
assert.Equal(t, len(tests), len(tokens))
100
+
assert.Len(t, tokens, len(tests))
101
101
102
102
// sort the tokens (insertion order by auto-incrementing primary key)
103
103
sort.Slice(tokens, func(i, j int) bool {
+2
-2
models/migrations/v1_22/v286_test.go
+2
-2
models/migrations/v1_22/v286_test.go
···
109
109
ok, err := x.ID(2).Get(repo)
110
110
require.NoError(t, err)
111
111
assert.True(t, ok)
112
-
assert.EqualValues(t, "sha1", repo.ObjectFormatName)
112
+
assert.Equal(t, "sha1", repo.ObjectFormatName)
113
113
114
114
repo = new(Repository)
115
115
ok, err = x.ID(id).Get(repo)
116
116
require.NoError(t, err)
117
117
assert.True(t, ok)
118
-
assert.EqualValues(t, "sha256", repo.ObjectFormatName)
118
+
assert.Equal(t, "sha256", repo.ObjectFormatName)
119
119
}
+1
-1
models/org_team_test.go
+1
-1
models/org_team_test.go
···
82
82
assert.True(t, strings.HasPrefix(team.Description, "A long description!"))
83
83
84
84
access := unittest.AssertExistsAndLoadBean(t, &access_model.Access{UserID: 4, RepoID: 3})
85
-
assert.EqualValues(t, perm.AccessModeAdmin, access.Mode)
85
+
assert.Equal(t, perm.AccessModeAdmin, access.Mode)
86
86
87
87
unittest.CheckConsistencyFor(t, &organization.Team{ID: team.ID})
88
88
}
+1
-1
models/org_test.go
+1
-1
models/org_test.go
···
49
49
require.NoError(t, RemoveOrgUser(db.DefaultContext, orgID, userID))
50
50
unittest.AssertNotExistsBean(t, &organization.OrgUser{OrgID: orgID, UID: userID})
51
51
org = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: orgID})
52
-
assert.EqualValues(t, expectedNumMembers, org.NumMembers)
52
+
assert.Equal(t, expectedNumMembers, org.NumMembers)
53
53
}
54
54
testSuccess(3, 4)
55
55
testSuccess(3, 4)
+2
-2
models/organization/org.go
+2
-2
models/organization/org.go
···
195
195
}
196
196
197
197
func (opts FindOrgMembersOpts) PublicOnly() bool {
198
-
return opts.Doer == nil || !(opts.IsDoerMember || opts.Doer.IsAdmin)
198
+
return opts.Doer == nil || (!opts.IsDoerMember && !opts.Doer.IsAdmin)
199
199
}
200
200
201
201
// CountOrgMembers counts the organization's members
···
478
478
sess.And("is_public = ?", true)
479
479
}
480
480
481
-
if opts.ListOptions.PageSize > 0 {
481
+
if opts.PageSize > 0 {
482
482
sess = db.SetSessionPagination(sess, opts)
483
483
484
484
ous := make([]*OrgUser, 0, opts.PageSize)
+1
-1
models/organization/org_list_test.go
+1
-1
models/organization/org_list_test.go
+11
-11
models/organization/org_test.go
+11
-11
models/organization/org_test.go
···
136
136
test := func(orgID, userID int64, expected bool) {
137
137
isOwner, err := organization.IsOrganizationOwner(db.DefaultContext, orgID, userID)
138
138
require.NoError(t, err)
139
-
assert.EqualValues(t, expected, isOwner)
139
+
assert.Equal(t, expected, isOwner)
140
140
}
141
141
test(3, 2, true)
142
142
test(3, 3, false)
···
150
150
test := func(orgID, userID int64, expected bool) {
151
151
isMember, err := organization.IsOrganizationMember(db.DefaultContext, orgID, userID)
152
152
require.NoError(t, err)
153
-
assert.EqualValues(t, expected, isMember)
153
+
assert.Equal(t, expected, isMember)
154
154
}
155
155
test(3, 2, true)
156
156
test(3, 3, false)
···
165
165
test := func(orgID, userID int64, expected bool) {
166
166
isMember, err := organization.IsPublicMembership(db.DefaultContext, orgID, userID)
167
167
require.NoError(t, err)
168
-
assert.EqualValues(t, expected, isMember)
168
+
assert.Equal(t, expected, isMember)
169
169
}
170
170
test(3, 2, true)
171
171
test(3, 3, false)
···
188
188
sort.Slice(orgUsers, func(i, j int) bool {
189
189
return orgUsers[i].ID < orgUsers[j].ID
190
190
})
191
-
assert.EqualValues(t, []*organization.OrgUser{{
191
+
assert.Equal(t, []*organization.OrgUser{{
192
192
ID: 1,
193
193
OrgID: 3,
194
194
UID: 2,
···
255
255
require.NoError(t, err)
256
256
count, err := env.CountRepos()
257
257
require.NoError(t, err)
258
-
assert.EqualValues(t, expectedCount, count)
258
+
assert.Equal(t, expectedCount, count)
259
259
}
260
260
testSuccess(2, 3)
261
261
testSuccess(4, 2)
···
494
494
user := &user_model.User{ID: 1001}
495
495
t.Run("Anonymous", func(t *testing.T) {
496
496
t.Run("Public", func(t *testing.T) {
497
-
assert.EqualValues(t, perm.AccessModeRead, publicOrg.UnitPermission(db.DefaultContext, nil, unit.TypeCode))
497
+
assert.Equal(t, perm.AccessModeRead, publicOrg.UnitPermission(db.DefaultContext, nil, unit.TypeCode))
498
498
})
499
499
t.Run("Limited", func(t *testing.T) {
500
-
assert.EqualValues(t, perm.AccessModeNone, limitedOrg.UnitPermission(db.DefaultContext, nil, unit.TypeCode))
500
+
assert.Equal(t, perm.AccessModeNone, limitedOrg.UnitPermission(db.DefaultContext, nil, unit.TypeCode))
501
501
})
502
502
t.Run("Private", func(t *testing.T) {
503
-
assert.EqualValues(t, perm.AccessModeNone, privateOrg.UnitPermission(db.DefaultContext, nil, unit.TypeCode))
503
+
assert.Equal(t, perm.AccessModeNone, privateOrg.UnitPermission(db.DefaultContext, nil, unit.TypeCode))
504
504
})
505
505
})
506
506
507
507
t.Run("Logged in", func(t *testing.T) {
508
508
t.Run("Public", func(t *testing.T) {
509
-
assert.EqualValues(t, perm.AccessModeRead, publicOrg.UnitPermission(db.DefaultContext, user, unit.TypeCode))
509
+
assert.Equal(t, perm.AccessModeRead, publicOrg.UnitPermission(db.DefaultContext, user, unit.TypeCode))
510
510
})
511
511
t.Run("Limited", func(t *testing.T) {
512
-
assert.EqualValues(t, perm.AccessModeRead, limitedOrg.UnitPermission(db.DefaultContext, user, unit.TypeCode))
512
+
assert.Equal(t, perm.AccessModeRead, limitedOrg.UnitPermission(db.DefaultContext, user, unit.TypeCode))
513
513
})
514
514
t.Run("Private", func(t *testing.T) {
515
-
assert.EqualValues(t, perm.AccessModeNone, privateOrg.UnitPermission(db.DefaultContext, user, unit.TypeCode))
515
+
assert.Equal(t, perm.AccessModeNone, privateOrg.UnitPermission(db.DefaultContext, user, unit.TypeCode))
516
516
})
517
517
})
518
518
}
+1
-1
models/organization/org_user_test.go
+1
-1
models/organization/org_user_test.go
···
140
140
unittest.AssertExistsAndLoadBean(t, ou)
141
141
assert.Equal(t, isPublic, ou.IsPublic)
142
142
org = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: orgID})
143
-
assert.EqualValues(t, expectedNumMembers, org.NumMembers)
143
+
assert.Equal(t, expectedNumMembers, org.NumMembers)
144
144
}
145
145
146
146
setting.Service.DefaultOrgMemberVisible = false
+3
-3
models/organization/team_test.go
+3
-3
models/organization/team_test.go
···
77
77
testSuccess := func(orgID int64, name string) {
78
78
team, err := organization.GetTeam(db.DefaultContext, orgID, name)
79
79
require.NoError(t, err)
80
-
assert.EqualValues(t, orgID, team.OrgID)
80
+
assert.Equal(t, orgID, team.OrgID)
81
81
assert.Equal(t, name, team.Name)
82
82
}
83
83
testSuccess(3, "Owners")
···
95
95
testSuccess := func(teamID int64) {
96
96
team, err := organization.GetTeamByID(db.DefaultContext, teamID)
97
97
require.NoError(t, err)
98
-
assert.EqualValues(t, teamID, team.ID)
98
+
assert.Equal(t, teamID, team.ID)
99
99
}
100
100
testSuccess(1)
101
101
testSuccess(2)
···
163
163
teams, err := organization.GetUserOrgTeams(db.DefaultContext, orgID, userID)
164
164
require.NoError(t, err)
165
165
for _, team := range teams {
166
-
assert.EqualValues(t, orgID, team.OrgID)
166
+
assert.Equal(t, orgID, team.OrgID)
167
167
unittest.AssertExistsAndLoadBean(t, &organization.TeamUser{TeamID: team.ID, UID: userID})
168
168
}
169
169
}
+1
-1
models/perm/access/access.go
+1
-1
models/perm/access/access.go
+3
-3
models/project/column_test.go
+3
-3
models/project/column_test.go
···
98
98
columnsAfter, err := project1.GetColumns(db.DefaultContext)
99
99
require.NoError(t, err)
100
100
assert.Len(t, columnsAfter, 3)
101
-
assert.EqualValues(t, columns[1].ID, columnsAfter[0].ID)
102
-
assert.EqualValues(t, columns[2].ID, columnsAfter[1].ID)
103
-
assert.EqualValues(t, columns[0].ID, columnsAfter[2].ID)
101
+
assert.Equal(t, columns[1].ID, columnsAfter[0].ID)
102
+
assert.Equal(t, columns[2].ID, columnsAfter[1].ID)
103
+
assert.Equal(t, columns[0].ID, columnsAfter[2].ID)
104
104
}
105
105
106
106
func Test_NewColumn(t *testing.T) {
+2
-2
models/project/project_test.go
+2
-2
models/project/project_test.go
···
114
114
OrderBy: GetSearchOrderByBySortType(tt.sortType),
115
115
})
116
116
require.NoError(t, err)
117
-
assert.EqualValues(t, int64(6), count)
117
+
assert.Equal(t, int64(6), count)
118
118
if assert.Len(t, projects, 6) {
119
119
for i := range projects {
120
-
assert.EqualValues(t, tt.wants[i], projects[i].ID)
120
+
assert.Equal(t, tt.wants[i], projects[i].ID)
121
121
}
122
122
}
123
123
}
+5
-5
models/repo/collaboration_test.go
+5
-5
models/repo/collaboration_test.go
···
27
27
require.NoError(t, err)
28
28
assert.Len(t, collaborators, int(expectedLen))
29
29
for _, collaborator := range collaborators {
30
-
assert.EqualValues(t, collaborator.User.ID, collaborator.Collaboration.UserID)
31
-
assert.EqualValues(t, repoID, collaborator.Collaboration.RepoID)
30
+
assert.Equal(t, collaborator.User.ID, collaborator.Collaboration.UserID)
31
+
assert.Equal(t, repoID, collaborator.Collaboration.RepoID)
32
32
}
33
33
}
34
34
test(1)
···
47
47
require.NoError(t, err)
48
48
assert.Len(t, collaborators2, 1)
49
49
50
-
assert.NotEqualValues(t, collaborators1[0].ID, collaborators2[0].ID)
50
+
assert.NotEqual(t, collaborators1[0].ID, collaborators2[0].ID)
51
51
}
52
52
53
53
func TestRepository_IsCollaborator(t *testing.T) {
···
72
72
require.NoError(t, repo_model.ChangeCollaborationAccessMode(db.DefaultContext, repo, 4, perm.AccessModeAdmin))
73
73
74
74
collaboration := unittest.AssertExistsAndLoadBean(t, &repo_model.Collaboration{RepoID: repo.ID, UserID: 4})
75
-
assert.EqualValues(t, perm.AccessModeAdmin, collaboration.Mode)
75
+
assert.Equal(t, perm.AccessModeAdmin, collaboration.Mode)
76
76
77
77
access := unittest.AssertExistsAndLoadBean(t, &access_model.Access{UserID: 4, RepoID: repo.ID})
78
-
assert.EqualValues(t, perm.AccessModeAdmin, access.Mode)
78
+
assert.Equal(t, perm.AccessModeAdmin, access.Mode)
79
79
80
80
require.NoError(t, repo_model.ChangeCollaborationAccessMode(db.DefaultContext, repo, 4, perm.AccessModeAdmin))
81
81
+1
-1
models/repo/pushmirror_test.go
+1
-1
models/repo/pushmirror_test.go
···
67
67
t.Run("Normal retrieval", func(t *testing.T) {
68
68
actualPrivateKey, err := m.Privatekey()
69
69
require.NoError(t, err)
70
-
assert.EqualValues(t, privateKey, actualPrivateKey)
70
+
assert.Equal(t, privateKey, actualPrivateKey)
71
71
})
72
72
73
73
t.Run("Incorrect retrieval", func(t *testing.T) {
+6
-5
models/repo/repo.go
+6
-5
models/repo/repo.go
···
402
402
return ru
403
403
}
404
404
405
-
if tp == unit.TypeExternalWiki {
405
+
switch tp {
406
+
case unit.TypeExternalWiki:
406
407
return &RepoUnit{
407
408
Type: tp,
408
409
Config: new(ExternalWikiConfig),
409
410
}
410
-
} else if tp == unit.TypeExternalTracker {
411
+
case unit.TypeExternalTracker:
411
412
return &RepoUnit{
412
413
Type: tp,
413
414
Config: new(ExternalTrackerConfig),
414
415
}
415
-
} else if tp == unit.TypePullRequests {
416
+
case unit.TypePullRequests:
416
417
return &RepoUnit{
417
418
Type: tp,
418
419
Config: new(PullRequestsConfig),
419
420
}
420
-
} else if tp == unit.TypeIssues {
421
+
case unit.TypeIssues:
421
422
return &RepoUnit{
422
423
Type: tp,
423
424
Config: new(IssuesConfig),
424
425
}
425
-
} else if tp == unit.TypeActions {
426
+
case unit.TypeActions:
426
427
return &RepoUnit{
427
428
Type: tp,
428
429
Config: new(ActionsConfig),
+1
-1
models/repo/repo_list_test.go
+1
-1
models/repo/repo_list_test.go
+5
-5
models/repo/repo_unit_test.go
+5
-5
models/repo/repo_unit_test.go
···
16
16
func TestActionsConfig(t *testing.T) {
17
17
cfg := &ActionsConfig{}
18
18
cfg.DisableWorkflow("test1.yaml")
19
-
assert.EqualValues(t, []string{"test1.yaml"}, cfg.DisabledWorkflows)
19
+
assert.Equal(t, []string{"test1.yaml"}, cfg.DisabledWorkflows)
20
20
21
21
cfg.DisableWorkflow("test1.yaml")
22
-
assert.EqualValues(t, []string{"test1.yaml"}, cfg.DisabledWorkflows)
22
+
assert.Equal(t, []string{"test1.yaml"}, cfg.DisabledWorkflows)
23
23
24
24
cfg.EnableWorkflow("test1.yaml")
25
-
assert.EqualValues(t, []string{}, cfg.DisabledWorkflows)
25
+
assert.Equal(t, []string{}, cfg.DisabledWorkflows)
26
26
27
27
cfg.EnableWorkflow("test1.yaml")
28
-
assert.EqualValues(t, []string{}, cfg.DisabledWorkflows)
28
+
assert.Equal(t, []string{}, cfg.DisabledWorkflows)
29
29
30
30
cfg.DisableWorkflow("test1.yaml")
31
31
cfg.DisableWorkflow("test2.yaml")
32
32
cfg.DisableWorkflow("test3.yaml")
33
-
assert.EqualValues(t, "test1.yaml,test2.yaml,test3.yaml", cfg.ToString())
33
+
assert.Equal(t, "test1.yaml,test2.yaml,test3.yaml", cfg.ToString())
34
34
}
35
35
36
36
func TestRepoUnitAccessMode(t *testing.T) {
+1
-1
models/repo/topic_test.go
+1
-1
models/repo/topic_test.go
···
53
53
repo2NrOfTopics = 2
54
54
totalNrOfTopics++
55
55
topic := unittest.AssertExistsAndLoadBean(t, &repo_model.Topic{Name: "gitea"})
56
-
assert.EqualValues(t, 1, topic.RepoCount)
56
+
assert.Equal(t, 1, topic.RepoCount)
57
57
58
58
topics, _, err = repo_model.FindTopics(db.DefaultContext, &repo_model.FindTopicOptions{})
59
59
require.NoError(t, err)
+1
-1
models/repo/watch_test.go
+1
-1
models/repo/watch_test.go
···
36
36
// One watchers are inactive, thus minus 1
37
37
assert.Len(t, watches, repo.NumWatches-1)
38
38
for _, watch := range watches {
39
-
assert.EqualValues(t, repo.ID, watch.RepoID)
39
+
assert.Equal(t, repo.ID, watch.RepoID)
40
40
}
41
41
42
42
watches, err = repo_model.GetWatchers(db.DefaultContext, unittest.NonexistentID)
+2
-2
models/repo_test.go
+2
-2
models/repo_test.go
···
30
30
31
31
issue2 := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2})
32
32
assert.NotNil(t, issue2)
33
-
assert.EqualValues(t, 0, issue2.NumComments) // the fixture data is wrong, but we don't fix it here
33
+
assert.Equal(t, 0, issue2.NumComments) // the fixture data is wrong, but we don't fix it here
34
34
35
35
require.NoError(t, repoStatsCorrectIssueNumComments(db.DefaultContext, 2))
36
36
// reload the issue
37
37
issue2 = unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: 2})
38
-
assert.EqualValues(t, 1, issue2.NumComments)
38
+
assert.Equal(t, 1, issue2.NumComments)
39
39
}
+1
-1
models/repo_transfer_test.go
+1
-1
models/repo_transfer_test.go
···
23
23
pendingTransferIDs, err := GetPendingTransferIDs(db.DefaultContext, reciepient.ID, doer.ID)
24
24
require.NoError(t, err)
25
25
if assert.Len(t, pendingTransferIDs, 1) {
26
-
assert.EqualValues(t, pendingTransfer.ID, pendingTransferIDs[0])
26
+
assert.Equal(t, pendingTransfer.ID, pendingTransferIDs[0])
27
27
}
28
28
}
+6
-6
models/system/setting_test.go
+6
-6
models/system/setting_test.go
···
22
22
23
23
rev, settings, err := system.GetAllSettings(db.DefaultContext)
24
24
require.NoError(t, err)
25
-
assert.EqualValues(t, 1, rev)
25
+
assert.Equal(t, 1, rev)
26
26
assert.Len(t, settings, 1) // there is only one "revision" key
27
27
28
28
err = system.SetSettings(db.DefaultContext, map[string]string{keyName: "true"})
29
29
require.NoError(t, err)
30
30
rev, settings, err = system.GetAllSettings(db.DefaultContext)
31
31
require.NoError(t, err)
32
-
assert.EqualValues(t, 2, rev)
32
+
assert.Equal(t, 2, rev)
33
33
assert.Len(t, settings, 2)
34
-
assert.EqualValues(t, "true", settings[keyName])
34
+
assert.Equal(t, "true", settings[keyName])
35
35
36
36
err = system.SetSettings(db.DefaultContext, map[string]string{keyName: "false"})
37
37
require.NoError(t, err)
38
38
rev, settings, err = system.GetAllSettings(db.DefaultContext)
39
39
require.NoError(t, err)
40
-
assert.EqualValues(t, 3, rev)
40
+
assert.Equal(t, 3, rev)
41
41
assert.Len(t, settings, 2)
42
-
assert.EqualValues(t, "false", settings[keyName])
42
+
assert.Equal(t, "false", settings[keyName])
43
43
44
44
// setting the same value should not trigger DuplicateKey error, and the "version" should be increased
45
45
err = system.SetSettings(db.DefaultContext, map[string]string{keyName: "false"})
···
48
48
rev, settings, err = system.GetAllSettings(db.DefaultContext)
49
49
require.NoError(t, err)
50
50
assert.Len(t, settings, 2)
51
-
assert.EqualValues(t, 4, rev)
51
+
assert.Equal(t, 4, rev)
52
52
}
+5
-5
models/unittest/consistency.go
+5
-5
models/unittest/consistency.go
···
49
49
require.NoError(t, err)
50
50
f := consistencyCheckMap[tb.Name]
51
51
if f == nil {
52
-
assert.FailNow(t, "unknown bean type: %#v", bean)
52
+
assert.FailNow(t, "unknown bean type", "%#v", bean)
53
53
}
54
54
f(t, bean)
55
55
}
···
73
73
AssertCountByCond(t, "follow", builder.Eq{"user_id": user.int("ID")}, user.int("NumFollowing"))
74
74
AssertCountByCond(t, "follow", builder.Eq{"follow_id": user.int("ID")}, user.int("NumFollowers"))
75
75
if user.int("Type") != modelsUserTypeOrganization {
76
-
assert.EqualValues(t, 0, user.int("NumMembers"), "Unexpected number of members for user id: %d", user.int("ID"))
77
-
assert.EqualValues(t, 0, user.int("NumTeams"), "Unexpected number of teams for user id: %d", user.int("ID"))
76
+
assert.Equal(t, 0, user.int("NumMembers"), "Unexpected number of members for user id: %d", user.int("ID"))
77
+
assert.Equal(t, 0, user.int("NumTeams"), "Unexpected number of teams for user id: %d", user.int("ID"))
78
78
}
79
79
}
80
80
···
121
121
assert.EqualValues(t, issue.int("NumComments"), actual, "Unexpected number of comments for issue id: %d", issue.int("ID"))
122
122
if issue.bool("IsPull") {
123
123
prRow := AssertExistsAndLoadMap(t, "pull_request", builder.Eq{"issue_id": issue.int("ID")})
124
-
assert.EqualValues(t, parseInt(prRow["index"]), issue.int("Index"), "Unexpected index for issue id: %d", issue.int("ID"))
124
+
assert.Equal(t, parseInt(prRow["index"]), issue.int("Index"), "Unexpected index for issue id: %d", issue.int("ID"))
125
125
}
126
126
}
127
127
···
129
129
pr := reflectionWrap(bean)
130
130
issueRow := AssertExistsAndLoadMap(t, "issue", builder.Eq{"id": pr.int("IssueID")})
131
131
assert.True(t, parseBool(issueRow["is_pull"]))
132
-
assert.EqualValues(t, parseInt(issueRow["index"]), pr.int("Index"), "Unexpected index for pull request id: %d", pr.int("ID"))
132
+
assert.Equal(t, parseInt(issueRow["index"]), pr.int("Index"), "Unexpected index for pull request id: %d", pr.int("ID"))
133
133
}
134
134
135
135
checkForMilestoneConsistency := func(t *testing.T, bean any) {
+1
-1
models/unittest/mock_http.go
+1
-1
models/unittest/mock_http.go
···
67
67
for headerName, headerValues := range response.Header {
68
68
for _, headerValue := range headerValues {
69
69
if !slices.Contains(ignoredHeaders, strings.ToLower(headerName)) {
70
-
_, err := fixtureWriter.WriteString(fmt.Sprintf("%s: %s\n", headerName, headerValue))
70
+
_, err := fmt.Fprintf(fixtureWriter, "%s: %s\n", headerName, headerValue)
71
71
require.NoError(t, err, "writing the header of the HTTP response to the fixture file failed")
72
72
}
73
73
}
+3
-2
models/user/search.go
+3
-2
models/user/search.go
···
52
52
cond = builder.Eq{"type": opts.Type}
53
53
}
54
54
if opts.IncludeReserved {
55
-
if opts.Type == UserTypeIndividual {
55
+
switch opts.Type {
56
+
case UserTypeIndividual:
56
57
cond = cond.Or(builder.Eq{"type": UserTypeUserReserved}).Or(
57
58
builder.Eq{"type": UserTypeBot},
58
59
).Or(
59
60
builder.Eq{"type": UserTypeRemoteUser},
60
61
)
61
-
} else if opts.Type == UserTypeOrganization {
62
+
case UserTypeOrganization:
62
63
cond = cond.Or(builder.Eq{"type": UserTypeOrganizationReserved})
63
64
}
64
65
}
+4
-4
models/user/setting_test.go
+4
-4
models/user/setting_test.go
···
31
31
settings, err := user_model.GetSettings(db.DefaultContext, 99, []string{keyName})
32
32
require.NoError(t, err)
33
33
assert.Len(t, settings, 1)
34
-
assert.EqualValues(t, newSetting.SettingValue, settings[keyName].SettingValue)
34
+
assert.Equal(t, newSetting.SettingValue, settings[keyName].SettingValue)
35
35
36
36
settingValue, err := user_model.GetUserSetting(db.DefaultContext, 99, keyName)
37
37
require.NoError(t, err)
38
-
assert.EqualValues(t, newSetting.SettingValue, settingValue)
38
+
assert.Equal(t, newSetting.SettingValue, settingValue)
39
39
40
40
settingValue, err = user_model.GetUserSetting(db.DefaultContext, 99, "no_such")
41
41
require.NoError(t, err)
42
-
assert.EqualValues(t, "", settingValue)
42
+
assert.Empty(t, settingValue)
43
43
44
44
// updated setting
45
45
updatedSetting := &user_model.Setting{UserID: 99, SettingKey: keyName, SettingValue: "Updated"}
···
50
50
settings, err = user_model.GetUserAllSettings(db.DefaultContext, 99)
51
51
require.NoError(t, err)
52
52
assert.Len(t, settings, 1)
53
-
assert.EqualValues(t, updatedSetting.SettingValue, settings[updatedSetting.SettingKey].SettingValue)
53
+
assert.Equal(t, updatedSetting.SettingValue, settings[updatedSetting.SettingKey].SettingValue)
54
54
55
55
// delete setting
56
56
err = user_model.DeleteUserSetting(db.DefaultContext, 99, keyName)
+1
-1
models/user/user.go
+1
-1
models/user/user.go
···
700
700
u.MaxRepoCreation = -1
701
701
u.Theme = setting.UI.DefaultTheme
702
702
u.IsRestricted = setting.Service.DefaultUserIsRestricted
703
-
u.IsActive = !(setting.Service.RegisterEmailConfirm || setting.Service.RegisterManualConfirm)
703
+
u.IsActive = !setting.Service.RegisterEmailConfirm && !setting.Service.RegisterManualConfirm
704
704
705
705
// Ensure consistency of the dates.
706
706
if u.UpdatedUnix < u.CreatedUnix {
+10
-10
models/user/user_test.go
+10
-10
models/user/user_test.go
···
153
153
cassText := fmt.Sprintf("ids: %v, opts: %v", expectedUserOrOrgIDs, opts)
154
154
if assert.Len(t, users, len(expectedUserOrOrgIDs), "case: %s", cassText) {
155
155
for i, expectedID := range expectedUserOrOrgIDs {
156
-
assert.EqualValues(t, expectedID, users[i].ID, "case: %s", cassText)
156
+
assert.Equal(t, expectedID, users[i].ID, "case: %s", cassText)
157
157
}
158
158
}
159
159
}
···
616
616
{ID: 2, Visibility: structs.VisibleTypePrivate}: true,
617
617
}
618
618
for kase, expected := range kases {
619
-
assert.EqualValues(t, expected, nil == user_model.ValidateUser(kase))
619
+
assert.Equal(t, expected, nil == user_model.ValidateUser(kase))
620
620
}
621
621
}
622
622
···
644
644
for _, testCase := range testCases {
645
645
normalizedName, err := user_model.NormalizeUserName(testCase.Input)
646
646
require.NoError(t, err)
647
-
assert.EqualValues(t, testCase.Expected, normalizedName)
647
+
assert.Equal(t, testCase.Expected, normalizedName)
648
648
if testCase.IsNormalizedValid {
649
649
require.NoError(t, user_model.IsUsableUsername(normalizedName))
650
650
} else {
···
674
674
for _, testCase := range testCases {
675
675
t.Run(testCase.result, func(t *testing.T) {
676
676
testUser := &user_model.User{FullName: testCase.fullName, Email: testCase.mail}
677
-
assert.EqualValues(t, testCase.result, testUser.EmailTo())
677
+
assert.Equal(t, testCase.result, testUser.EmailTo())
678
678
})
679
679
}
680
680
681
681
t.Run("Override user's email", func(t *testing.T) {
682
682
testUser := &user_model.User{FullName: "Christine Jorgensen", Email: "christine@test.com"}
683
-
assert.EqualValues(t, `"Christine Jorgensen" <christine@example.org>`, testUser.EmailTo("christine@example.org"))
683
+
assert.Equal(t, `"Christine Jorgensen" <christine@example.org>`, testUser.EmailTo("christine@example.org"))
684
684
})
685
685
}
686
686
···
736
736
authToken, err := auth.FindAuthToken(db.DefaultContext, lookupKey, auth.UserActivation)
737
737
require.NoError(t, err)
738
738
assert.False(t, authToken.IsExpired())
739
-
assert.EqualValues(t, authToken.HashedValidator, auth.HashValidator(rawValidator))
739
+
assert.Equal(t, authToken.HashedValidator, auth.HashValidator(rawValidator))
740
740
741
741
authToken.Expiry = authToken.Expiry.Add(-int64(setting.Service.ActiveCodeLives) * 60)
742
742
assert.True(t, authToken.IsExpired())
···
763
763
t.Run("No delete", func(t *testing.T) {
764
764
u, _, err := user_model.VerifyUserAuthorizationToken(db.DefaultContext, code, auth.UserActivation)
765
765
require.NoError(t, err)
766
-
assert.EqualValues(t, user.ID, u.ID)
766
+
assert.Equal(t, user.ID, u.ID)
767
767
768
768
authToken, err := auth.FindAuthToken(db.DefaultContext, lookupKey, auth.UserActivation)
769
769
require.NoError(t, err)
···
773
773
t.Run("Delete", func(t *testing.T) {
774
774
u, deleteToken, err := user_model.VerifyUserAuthorizationToken(db.DefaultContext, code, auth.UserActivation)
775
775
require.NoError(t, err)
776
-
assert.EqualValues(t, user.ID, u.ID)
776
+
assert.Equal(t, user.ID, u.ID)
777
777
require.NoError(t, deleteToken())
778
778
779
779
authToken, err := auth.FindAuthToken(db.DefaultContext, lookupKey, auth.UserActivation)
···
803
803
user.Pronouns = ""
804
804
user.KeepPronounsPrivate = false
805
805
806
-
assert.Equal(t, "", user.GetPronouns(false))
806
+
assert.Empty(t, user.GetPronouns(false))
807
807
})
808
808
t.Run("EmptyPronounsIfSetButPrivateAndNotLoggedIn", func(t *testing.T) {
809
809
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
810
810
user.Pronouns = "any"
811
811
user.KeepPronounsPrivate = true
812
812
813
-
assert.Equal(t, "", user.GetPronouns(false))
813
+
assert.Empty(t, user.GetPronouns(false))
814
814
})
815
815
t.Run("ReturnPronounsIfSetAndNotPrivateAndNotLoggedIn", func(t *testing.T) {
816
816
user := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
+3
-2
models/webhook/hooktask.go
+3
-2
models/webhook/hooktask.go
···
198
198
func CleanupHookTaskTable(ctx context.Context, cleanupType HookTaskCleanupType, olderThan time.Duration, numberToKeep int) error {
199
199
log.Trace("Doing: CleanupHookTaskTable")
200
200
201
-
if cleanupType == OlderThan {
201
+
switch cleanupType {
202
+
case OlderThan:
202
203
deleteOlderThan := time.Now().Add(-olderThan).UnixNano()
203
204
deletes, err := db.GetEngine(ctx).
204
205
Where("is_delivered = ? and delivered < ?", true, deleteOlderThan).
···
207
208
return err
208
209
}
209
210
log.Trace("Deleted %d rows from hook_task", deletes)
210
-
} else if cleanupType == PerWebhook {
211
+
case PerWebhook:
211
212
hookIDs := make([]int64, 0, 10)
212
213
err := db.GetEngine(ctx).
213
214
Table("webhook").
+23
-23
models/webhook/webhook.go
+23
-23
models/webhook/webhook.go
···
170
170
// HasCreateEvent returns true if hook enabled create event.
171
171
func (w *Webhook) HasCreateEvent() bool {
172
172
return w.SendEverything ||
173
-
(w.ChooseEvents && w.HookEvents.Create)
173
+
(w.ChooseEvents && w.Create)
174
174
}
175
175
176
176
// HasDeleteEvent returns true if hook enabled delete event.
177
177
func (w *Webhook) HasDeleteEvent() bool {
178
178
return w.SendEverything ||
179
-
(w.ChooseEvents && w.HookEvents.Delete)
179
+
(w.ChooseEvents && w.Delete)
180
180
}
181
181
182
182
// HasForkEvent returns true if hook enabled fork event.
183
183
func (w *Webhook) HasForkEvent() bool {
184
184
return w.SendEverything ||
185
-
(w.ChooseEvents && w.HookEvents.Fork)
185
+
(w.ChooseEvents && w.Fork)
186
186
}
187
187
188
188
// HasIssuesEvent returns true if hook enabled issues event.
189
189
func (w *Webhook) HasIssuesEvent() bool {
190
190
return w.SendEverything ||
191
-
(w.ChooseEvents && w.HookEvents.Issues)
191
+
(w.ChooseEvents && w.Issues)
192
192
}
193
193
194
194
// HasIssuesAssignEvent returns true if hook enabled issues assign event.
195
195
func (w *Webhook) HasIssuesAssignEvent() bool {
196
196
return w.SendEverything ||
197
-
(w.ChooseEvents && w.HookEvents.IssueAssign)
197
+
(w.ChooseEvents && w.IssueAssign)
198
198
}
199
199
200
200
// HasIssuesLabelEvent returns true if hook enabled issues label event.
201
201
func (w *Webhook) HasIssuesLabelEvent() bool {
202
202
return w.SendEverything ||
203
-
(w.ChooseEvents && w.HookEvents.IssueLabel)
203
+
(w.ChooseEvents && w.IssueLabel)
204
204
}
205
205
206
206
// HasIssuesMilestoneEvent returns true if hook enabled issues milestone event.
207
207
func (w *Webhook) HasIssuesMilestoneEvent() bool {
208
208
return w.SendEverything ||
209
-
(w.ChooseEvents && w.HookEvents.IssueMilestone)
209
+
(w.ChooseEvents && w.IssueMilestone)
210
210
}
211
211
212
212
// HasIssueCommentEvent returns true if hook enabled issue_comment event.
213
213
func (w *Webhook) HasIssueCommentEvent() bool {
214
214
return w.SendEverything ||
215
-
(w.ChooseEvents && w.HookEvents.IssueComment)
215
+
(w.ChooseEvents && w.IssueComment)
216
216
}
217
217
218
218
// HasPushEvent returns true if hook enabled push event.
219
219
func (w *Webhook) HasPushEvent() bool {
220
220
return w.PushOnly || w.SendEverything ||
221
-
(w.ChooseEvents && w.HookEvents.Push)
221
+
(w.ChooseEvents && w.Push)
222
222
}
223
223
224
224
// HasPullRequestEvent returns true if hook enabled pull request event.
225
225
func (w *Webhook) HasPullRequestEvent() bool {
226
226
return w.SendEverything ||
227
-
(w.ChooseEvents && w.HookEvents.PullRequest)
227
+
(w.ChooseEvents && w.PullRequest)
228
228
}
229
229
230
230
// HasPullRequestAssignEvent returns true if hook enabled pull request assign event.
231
231
func (w *Webhook) HasPullRequestAssignEvent() bool {
232
232
return w.SendEverything ||
233
-
(w.ChooseEvents && w.HookEvents.PullRequestAssign)
233
+
(w.ChooseEvents && w.PullRequestAssign)
234
234
}
235
235
236
236
// HasPullRequestLabelEvent returns true if hook enabled pull request label event.
237
237
func (w *Webhook) HasPullRequestLabelEvent() bool {
238
238
return w.SendEverything ||
239
-
(w.ChooseEvents && w.HookEvents.PullRequestLabel)
239
+
(w.ChooseEvents && w.PullRequestLabel)
240
240
}
241
241
242
242
// HasPullRequestMilestoneEvent returns true if hook enabled pull request milestone event.
243
243
func (w *Webhook) HasPullRequestMilestoneEvent() bool {
244
244
return w.SendEverything ||
245
-
(w.ChooseEvents && w.HookEvents.PullRequestMilestone)
245
+
(w.ChooseEvents && w.PullRequestMilestone)
246
246
}
247
247
248
248
// HasPullRequestCommentEvent returns true if hook enabled pull_request_comment event.
249
249
func (w *Webhook) HasPullRequestCommentEvent() bool {
250
250
return w.SendEverything ||
251
-
(w.ChooseEvents && w.HookEvents.PullRequestComment)
251
+
(w.ChooseEvents && w.PullRequestComment)
252
252
}
253
253
254
254
// HasPullRequestApprovedEvent returns true if hook enabled pull request review event.
255
255
func (w *Webhook) HasPullRequestApprovedEvent() bool {
256
256
return w.SendEverything ||
257
-
(w.ChooseEvents && w.HookEvents.PullRequestReview)
257
+
(w.ChooseEvents && w.PullRequestReview)
258
258
}
259
259
260
260
// HasPullRequestRejectedEvent returns true if hook enabled pull request review event.
261
261
func (w *Webhook) HasPullRequestRejectedEvent() bool {
262
262
return w.SendEverything ||
263
-
(w.ChooseEvents && w.HookEvents.PullRequestReview)
263
+
(w.ChooseEvents && w.PullRequestReview)
264
264
}
265
265
266
266
// HasPullRequestReviewCommentEvent returns true if hook enabled pull request review event.
267
267
func (w *Webhook) HasPullRequestReviewCommentEvent() bool {
268
268
return w.SendEverything ||
269
-
(w.ChooseEvents && w.HookEvents.PullRequestReview)
269
+
(w.ChooseEvents && w.PullRequestReview)
270
270
}
271
271
272
272
// HasPullRequestSyncEvent returns true if hook enabled pull request sync event.
273
273
func (w *Webhook) HasPullRequestSyncEvent() bool {
274
274
return w.SendEverything ||
275
-
(w.ChooseEvents && w.HookEvents.PullRequestSync)
275
+
(w.ChooseEvents && w.PullRequestSync)
276
276
}
277
277
278
278
// HasWikiEvent returns true if hook enabled wiki event.
279
279
func (w *Webhook) HasWikiEvent() bool {
280
280
return w.SendEverything ||
281
-
(w.ChooseEvents && w.HookEvent.Wiki)
281
+
(w.ChooseEvents && w.Wiki)
282
282
}
283
283
284
284
// HasReleaseEvent returns if hook enabled release event.
285
285
func (w *Webhook) HasReleaseEvent() bool {
286
286
return w.SendEverything ||
287
-
(w.ChooseEvents && w.HookEvents.Release)
287
+
(w.ChooseEvents && w.Release)
288
288
}
289
289
290
290
// HasRepositoryEvent returns if hook enabled repository event.
291
291
func (w *Webhook) HasRepositoryEvent() bool {
292
292
return w.SendEverything ||
293
-
(w.ChooseEvents && w.HookEvents.Repository)
293
+
(w.ChooseEvents && w.Repository)
294
294
}
295
295
296
296
// HasPackageEvent returns if hook enabled package event.
297
297
func (w *Webhook) HasPackageEvent() bool {
298
298
return w.SendEverything ||
299
-
(w.ChooseEvents && w.HookEvents.Package)
299
+
(w.ChooseEvents && w.Package)
300
300
}
301
301
302
302
// HasPullRequestReviewRequestEvent returns true if hook enabled pull request review request event.
303
303
func (w *Webhook) HasPullRequestReviewRequestEvent() bool {
304
304
return w.SendEverything ||
305
-
(w.ChooseEvents && w.HookEvents.PullRequestReviewRequest)
305
+
(w.ChooseEvents && w.PullRequestReviewRequest)
306
306
}
307
307
308
308
// EventCheckers returns event checkers
+9
-9
modules/assetfs/layered_test.go
+9
-9
modules/assetfs/layered_test.go
···
53
53
require.NoError(t, err)
54
54
bs, err := io.ReadAll(f)
55
55
require.NoError(t, err)
56
-
assert.EqualValues(t, "f1", string(bs))
56
+
assert.Equal(t, "f1", string(bs))
57
57
_ = f.Close()
58
58
59
59
assertRead := func(expected string, expectedErr error, elems ...string) {
···
77
77
78
78
files, err := assets.ListFiles(".", true)
79
79
require.NoError(t, err)
80
-
assert.EqualValues(t, []string{"f1", "f2", "fa"}, files)
80
+
assert.Equal(t, []string{"f1", "f2", "fa"}, files)
81
81
82
82
files, err = assets.ListFiles(".", false)
83
83
require.NoError(t, err)
84
-
assert.EqualValues(t, []string{"d1", "d2", "da"}, files)
84
+
assert.Equal(t, []string{"d1", "d2", "da"}, files)
85
85
86
86
files, err = assets.ListFiles(".")
87
87
require.NoError(t, err)
88
-
assert.EqualValues(t, []string{"d1", "d2", "da", "f1", "f2", "fa"}, files)
88
+
assert.Equal(t, []string{"d1", "d2", "da", "f1", "f2", "fa"}, files)
89
89
90
90
files, err = assets.ListAllFiles(".", true)
91
91
require.NoError(t, err)
92
-
assert.EqualValues(t, []string{"d1/f", "d2/f", "da/f", "f1", "f2", "fa"}, files)
92
+
assert.Equal(t, []string{"d1/f", "d2/f", "da/f", "f1", "f2", "fa"}, files)
93
93
94
94
files, err = assets.ListAllFiles(".", false)
95
95
require.NoError(t, err)
96
-
assert.EqualValues(t, []string{"d1", "d2", "da", "da/sub1", "da/sub2"}, files)
96
+
assert.Equal(t, []string{"d1", "d2", "da", "da/sub1", "da/sub2"}, files)
97
97
98
98
files, err = assets.ListAllFiles(".")
99
99
require.NoError(t, err)
100
-
assert.EqualValues(t, []string{
100
+
assert.Equal(t, []string{
101
101
"d1", "d1/f",
102
102
"d2", "d2/f",
103
103
"da", "da/f", "da/sub1", "da/sub2",
···
105
105
}, files)
106
106
107
107
assert.Empty(t, assets.GetFileLayerName("no-such"))
108
-
assert.EqualValues(t, "l1", assets.GetFileLayerName("f1"))
109
-
assert.EqualValues(t, "l2", assets.GetFileLayerName("f2"))
108
+
assert.Equal(t, "l1", assets.GetFileLayerName("f1"))
109
+
assert.Equal(t, "l2", assets.GetFileLayerName("f2"))
110
110
}
+2
-2
modules/avatar/avatar_test.go
+2
-2
modules/avatar/avatar_test.go
···
95
95
assert.NotEqual(t, origin, result)
96
96
decoded, err := png.Decode(bytes.NewReader(result))
97
97
require.NoError(t, err)
98
-
assert.EqualValues(t, scaledSize, decoded.Bounds().Max.X)
99
-
assert.EqualValues(t, scaledSize, decoded.Bounds().Max.Y)
98
+
assert.Equal(t, scaledSize, decoded.Bounds().Max.X)
99
+
assert.Equal(t, scaledSize, decoded.Bounds().Max.Y)
100
100
101
101
// if origin image is smaller than the default size, use the origin image
102
102
origin = newImgData(1)
+4
-4
modules/avatar/hash_test.go
+4
-4
modules/avatar/hash_test.go
···
19
19
var buff bytes.Buffer
20
20
png.Encode(&buff, myImage)
21
21
22
-
assert.EqualValues(t, "9ddb5bac41d57e72aa876321d0c09d71090c05f94bc625303801be2f3240d2cb", avatar.HashAvatar(1, buff.Bytes()))
23
-
assert.EqualValues(t, "9a5d44e5d637b9582a976676e8f3de1dccd877c2fe3e66ca3fab1629f2f47609", avatar.HashAvatar(8, buff.Bytes()))
24
-
assert.EqualValues(t, "ed7399158672088770de6f5211ce15528ebd675e92fc4fc060c025f4b2794ccb", avatar.HashAvatar(1024, buff.Bytes()))
25
-
assert.EqualValues(t, "161178642c7d59eb25a61dddced5e6b66eae1c70880d5f148b1b497b767e72d9", avatar.HashAvatar(1024, []byte{}))
22
+
assert.Equal(t, "9ddb5bac41d57e72aa876321d0c09d71090c05f94bc625303801be2f3240d2cb", avatar.HashAvatar(1, buff.Bytes()))
23
+
assert.Equal(t, "9a5d44e5d637b9582a976676e8f3de1dccd877c2fe3e66ca3fab1629f2f47609", avatar.HashAvatar(8, buff.Bytes()))
24
+
assert.Equal(t, "ed7399158672088770de6f5211ce15528ebd675e92fc4fc060c025f4b2794ccb", avatar.HashAvatar(1024, buff.Bytes()))
25
+
assert.Equal(t, "161178642c7d59eb25a61dddced5e6b66eae1c70880d5f148b1b497b767e72d9", avatar.HashAvatar(1024, []byte{}))
26
26
}
+2
-2
modules/base/tool_test.go
+2
-2
modules/base/tool_test.go
···
73
73
}
74
74
75
75
func TestTruncateString(t *testing.T) {
76
-
assert.Equal(t, "", TruncateString("foobar", 0))
76
+
assert.Empty(t, TruncateString("foobar", 0))
77
77
assert.Equal(t, "f", TruncateString("foobar", 1))
78
78
assert.Equal(t, "fo", TruncateString("foobar", 2))
79
79
assert.Equal(t, "foo", TruncateString("foobar", 3))
···
125
125
assert.Equal(t, "1.3k", FormatNumberSI(int64(1317)))
126
126
assert.Equal(t, "21.3M", FormatNumberSI(21317675))
127
127
assert.Equal(t, "45.7G", FormatNumberSI(45721317675))
128
-
assert.Equal(t, "", FormatNumberSI("test"))
128
+
assert.Empty(t, FormatNumberSI("test"))
129
129
}
+3
-3
modules/cache/cache_test.go
+3
-3
modules/cache/cache_test.go
···
48
48
return "", fmt.Errorf("some error")
49
49
})
50
50
require.Error(t, err)
51
-
assert.Equal(t, "", data)
51
+
assert.Empty(t, data)
52
52
53
53
data, err = GetString("key", func() (string, error) {
54
54
return "", nil
55
55
})
56
56
require.NoError(t, err)
57
-
assert.Equal(t, "", data)
57
+
assert.Empty(t, data)
58
58
59
59
data, err = GetString("key", func() (string, error) {
60
60
return "some data", nil
61
61
})
62
62
require.NoError(t, err)
63
-
assert.Equal(t, "", data)
63
+
assert.Empty(t, data)
64
64
Remove("key")
65
65
66
66
data, err = GetString("key", func() (string, error) {
+2
-2
modules/cache/context_test.go
+2
-2
modules/cache/context_test.go
···
23
23
SetContextData(ctx, field, "my_config1", 1)
24
24
v = GetContextData(ctx, field, "my_config1")
25
25
assert.NotNil(t, v)
26
-
assert.EqualValues(t, 1, v.(int))
26
+
assert.Equal(t, 1, v.(int))
27
27
28
28
RemoveContextData(ctx, field, "my_config1")
29
29
RemoveContextData(ctx, field, "my_config2") // remove a non-exist key
···
35
35
return 1, nil
36
36
})
37
37
require.NoError(t, err)
38
-
assert.EqualValues(t, 1, vInt)
38
+
assert.Equal(t, 1, vInt)
39
39
40
40
v = GetContextData(ctx, field, "my_config1")
41
41
assert.EqualValues(t, 1, v)
+1
-1
modules/charset/ambiguous_gen_test.go
+1
-1
modules/charset/ambiguous_gen_test.go
···
14
14
func TestAmbiguousCharacters(t *testing.T) {
15
15
for locale, ambiguous := range AmbiguousCharacters {
16
16
assert.Equal(t, locale, ambiguous.Locale)
17
-
assert.Equal(t, len(ambiguous.Confusable), len(ambiguous.With))
17
+
assert.Len(t, ambiguous.With, len(ambiguous.Confusable))
18
18
assert.True(t, sort.SliceIsSorted(ambiguous.Confusable, func(i, j int) bool {
19
19
return ambiguous.Confusable[i] < ambiguous.Confusable[j]
20
20
}))
+1
-1
modules/charset/charset_test.go
+1
-1
modules/charset/charset_test.go
···
253
253
input += "// Выключаем"
254
254
rd := ToUTF8WithFallbackReader(bytes.NewReader([]byte(input)), ConvertOpts{})
255
255
r, _ := io.ReadAll(rd)
256
-
assert.EqualValuesf(t, input, string(r), "testing string len=%d", testLen)
256
+
assert.Equalf(t, input, string(r), "testing string len=%d", testLen)
257
257
}
258
258
259
259
truncatedOneByteExtension := failFastBytes
+10
-10
modules/charset/escape_stream.go
+10
-10
modules/charset/escape_stream.go
···
151
151
e.escaped.Escaped = true
152
152
e.escaped.HasBadRunes = true
153
153
154
-
if err := e.PassthroughHTMLStreamer.StartTag("span", html.Attribute{
154
+
if err := e.StartTag("span", html.Attribute{
155
155
Key: "class",
156
156
Val: "broken-code-point",
157
157
}); err != nil {
···
161
161
return err
162
162
}
163
163
164
-
return e.PassthroughHTMLStreamer.EndTag("span")
164
+
return e.EndTag("span")
165
165
}
166
166
167
167
func (e *escapeStreamer) ambiguousRune(r, c rune) error {
168
168
e.escaped.Escaped = true
169
169
e.escaped.HasAmbiguous = true
170
170
171
-
if err := e.PassthroughHTMLStreamer.StartTag("span", html.Attribute{
171
+
if err := e.StartTag("span", html.Attribute{
172
172
Key: "class",
173
173
Val: "ambiguous-code-point",
174
174
}, html.Attribute{
···
177
177
}); err != nil {
178
178
return err
179
179
}
180
-
if err := e.PassthroughHTMLStreamer.StartTag("span", html.Attribute{
180
+
if err := e.StartTag("span", html.Attribute{
181
181
Key: "class",
182
182
Val: "char",
183
183
}); err != nil {
···
186
186
if err := e.PassthroughHTMLStreamer.Text(string(r)); err != nil {
187
187
return err
188
188
}
189
-
if err := e.PassthroughHTMLStreamer.EndTag("span"); err != nil {
189
+
if err := e.EndTag("span"); err != nil {
190
190
return err
191
191
}
192
192
193
-
return e.PassthroughHTMLStreamer.EndTag("span")
193
+
return e.EndTag("span")
194
194
}
195
195
196
196
func (e *escapeStreamer) invisibleRune(r rune) error {
197
197
e.escaped.Escaped = true
198
198
e.escaped.HasInvisible = true
199
199
200
-
if err := e.PassthroughHTMLStreamer.StartTag("span", html.Attribute{
200
+
if err := e.StartTag("span", html.Attribute{
201
201
Key: "class",
202
202
Val: "escaped-code-point",
203
203
}, html.Attribute{
···
206
206
}); err != nil {
207
207
return err
208
208
}
209
-
if err := e.PassthroughHTMLStreamer.StartTag("span", html.Attribute{
209
+
if err := e.StartTag("span", html.Attribute{
210
210
Key: "class",
211
211
Val: "char",
212
212
}); err != nil {
···
215
215
if err := e.PassthroughHTMLStreamer.Text(string(r)); err != nil {
216
216
return err
217
217
}
218
-
if err := e.PassthroughHTMLStreamer.EndTag("span"); err != nil {
218
+
if err := e.EndTag("span"); err != nil {
219
219
return err
220
220
}
221
221
222
-
return e.PassthroughHTMLStreamer.EndTag("span")
222
+
return e.EndTag("span")
223
223
}
224
224
225
225
type runeCountType struct {
+1
-1
modules/charset/escape_test.go
+1
-1
modules/charset/escape_test.go
···
190
190
assert.EqualValues(t, `a<span class="escaped-code-point" data-escaped="[U+00A0]"><span class="char"> </span></span>test`, out)
191
191
192
192
_, out = EscapeControlHTML(input, &translation.MockLocale{}, testContext)
193
-
assert.EqualValues(t, input, out)
193
+
assert.Equal(t, input, out)
194
194
}
+1
-1
modules/container/set_test.go
+1
-1
modules/container/set_test.go
+7
-7
modules/csv/csv_test.go
+7
-7
modules/csv/csv_test.go
···
101
101
for n, c := range cases {
102
102
rd, err := CreateReaderAndDetermineDelimiter(nil, strings.NewReader(decodeSlashes(t, c.csv)))
103
103
require.NoError(t, err, "case %d: should not throw error: %v\n", n, err)
104
-
assert.EqualValues(t, c.expectedDelimiter, rd.Comma, "case %d: delimiter should be '%c', got '%c'", n, c.expectedDelimiter, rd.Comma)
104
+
assert.Equal(t, c.expectedDelimiter, rd.Comma, "case %d: delimiter should be '%c', got '%c'", n, c.expectedDelimiter, rd.Comma)
105
105
rows, err := rd.ReadAll()
106
106
require.NoError(t, err, "case %d: should not throw error: %v\n", n, err)
107
-
assert.EqualValues(t, c.expectedRows, rows, "case %d: rows should be equal", n)
107
+
assert.Equal(t, c.expectedRows, rows, "case %d: rows should be equal", n)
108
108
}
109
109
}
110
110
···
236
236
Ctx: git.DefaultContext,
237
237
RelativePath: c.filename,
238
238
}, []byte(decodeSlashes(t, c.csv)))
239
-
assert.EqualValues(t, c.expectedDelimiter, delimiter, "case %d: delimiter should be equal, expected '%c' got '%c'", n, c.expectedDelimiter, delimiter)
239
+
assert.Equal(t, c.expectedDelimiter, delimiter, "case %d: delimiter should be equal, expected '%c' got '%c'", n, c.expectedDelimiter, delimiter)
240
240
}
241
241
}
242
242
···
301
301
302
302
for n, c := range cases {
303
303
modifiedText := removeQuotedString(decodeSlashes(t, c.text))
304
-
assert.EqualValues(t, c.expectedText, modifiedText, "case %d: modified text should be equal", n)
304
+
assert.Equal(t, c.expectedText, modifiedText, "case %d: modified text should be equal", n)
305
305
}
306
306
}
307
307
···
456
456
457
457
for n, c := range cases {
458
458
delimiter := guessDelimiter([]byte(decodeSlashes(t, c.csv)))
459
-
assert.EqualValues(t, c.expectedDelimiter, delimiter, "case %d: delimiter should be equal, expected '%c' got '%c'", n, c.expectedDelimiter, delimiter)
459
+
assert.Equal(t, c.expectedDelimiter, delimiter, "case %d: delimiter should be equal, expected '%c' got '%c'", n, c.expectedDelimiter, delimiter)
460
460
}
461
461
}
462
462
···
548
548
549
549
for n, c := range cases {
550
550
delimiter := guessFromBeforeAfterQuotes([]byte(decodeSlashes(t, c.csv)))
551
-
assert.EqualValues(t, c.expectedDelimiter, delimiter, "case %d: delimiter should be equal, expected '%c' got '%c'", n, c.expectedDelimiter, delimiter)
551
+
assert.Equal(t, c.expectedDelimiter, delimiter, "case %d: delimiter should be equal, expected '%c' got '%c'", n, c.expectedDelimiter, delimiter)
552
552
}
553
553
}
554
554
···
584
584
require.Error(t, err, "case %d: expected an error to be returned", n)
585
585
} else {
586
586
require.NoError(t, err, "case %d: no error was expected, got error: %v", n, err)
587
-
assert.EqualValues(t, c.expectedMessage, message, "case %d: messages should be equal, expected '%s' got '%s'", n, c.expectedMessage, message)
587
+
assert.Equal(t, c.expectedMessage, message, "case %d: messages should be equal, expected '%s' got '%s'", n, c.expectedMessage, message)
588
588
}
589
589
}
590
590
}
+2
-2
modules/git/command_test.go
+2
-2
modules/git/command_test.go
···
55
55
56
56
func TestCommandString(t *testing.T) {
57
57
cmd := NewCommandContextNoGlobals(t.Context(), "a", "-m msg", "it's a test", `say "hello"`)
58
-
assert.EqualValues(t, cmd.prog+` a "-m msg" "it's a test" "say \"hello\""`, cmd.String())
58
+
assert.Equal(t, cmd.prog+` a "-m msg" "it's a test" "say \"hello\""`, cmd.String())
59
59
60
60
cmd = NewCommandContextNoGlobals(t.Context(), "url: https://a:b@c/")
61
-
assert.EqualValues(t, cmd.prog+` "url: https://sanitized-credential@c/"`, cmd.toString(true))
61
+
assert.Equal(t, cmd.prog+` "url: https://sanitized-credential@c/"`, cmd.toString(true))
62
62
}
63
63
64
64
func TestGrepOnlyFunction(t *testing.T) {
+1
-1
modules/git/commit.go
+1
-1
modules/git/commit.go
+4
-4
modules/git/commit_sha256_test.go
+4
-4
modules/git/commit_sha256_test.go
···
107
107
return
108
108
}
109
109
assert.EqualValues(t, sha, commitFromReader.ID)
110
-
assert.EqualValues(t, `-----BEGIN PGP SIGNATURE-----
110
+
assert.Equal(t, `-----BEGIN PGP SIGNATURE-----
111
111
112
112
iQIrBAABCgAtFiEES+fB08xlgTrzSdQvhkUIsBsmec8FAmU/wKoPHGFtYWplckBz
113
113
dXNlLmRlAAoJEIZFCLAbJnnP4s4PQIJATa++WPzR6/H4etT7bsOGoMyguEJYyWOd
···
124
124
=xybZ
125
125
-----END PGP SIGNATURE-----
126
126
`, commitFromReader.Signature.Signature)
127
-
assert.EqualValues(t, `tree e7f9e96dd79c09b078cac8b303a7d3b9d65ff9b734e86060a4d20409fd379f9e
127
+
assert.Equal(t, `tree e7f9e96dd79c09b078cac8b303a7d3b9d65ff9b734e86060a4d20409fd379f9e
128
128
parent 26e9ccc29fad747e9c5d9f4c9ddeb7eff61cc45ef6a8dc258cbeb181afc055e8
129
129
author Adam Majer <amajer@suse.de> 1698676906 +0100
130
130
committer Adam Majer <amajer@suse.de> 1698676906 +0100
131
131
132
132
signed commit`, commitFromReader.Signature.Payload)
133
-
assert.EqualValues(t, "Adam Majer <amajer@suse.de>", commitFromReader.Author.String())
133
+
assert.Equal(t, "Adam Majer <amajer@suse.de>", commitFromReader.Author.String())
134
134
135
135
commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n\n"))
136
136
require.NoError(t, err)
137
137
commitFromReader.CommitMessage += "\n\n"
138
138
commitFromReader.Signature.Payload += "\n\n"
139
-
assert.EqualValues(t, commitFromReader, commitFromReader2)
139
+
assert.Equal(t, commitFromReader, commitFromReader2)
140
140
}
141
141
142
142
func TestHasPreviousCommitSha256(t *testing.T) {
+8
-8
modules/git/commit_test.go
+8
-8
modules/git/commit_test.go
···
92
92
require.NoError(t, err)
93
93
require.NotNil(t, commitFromReader)
94
94
assert.EqualValues(t, sha, commitFromReader.ID)
95
-
assert.EqualValues(t, `-----BEGIN PGP SIGNATURE-----
95
+
assert.Equal(t, `-----BEGIN PGP SIGNATURE-----
96
96
97
97
iQIzBAABCAAdFiEEWPb2jX6FS2mqyJRQLmK0HJOGlEMFAl00zmEACgkQLmK0HJOG
98
98
lEMDFBAAhQKKqLD1VICygJMEB8t1gBmNLgvziOLfpX4KPWdPtBk3v/QJ7OrfMrVK
···
109
109
=FRsO
110
110
-----END PGP SIGNATURE-----
111
111
`, commitFromReader.Signature.Signature)
112
-
assert.EqualValues(t, `tree f1a6cb52b2d16773290cefe49ad0684b50a4f930
112
+
assert.Equal(t, `tree f1a6cb52b2d16773290cefe49ad0684b50a4f930
113
113
parent 37991dec2c8e592043f47155ce4808d4580f9123
114
114
author silverwind <me@silverwind.io> 1563741793 +0200
115
115
committer silverwind <me@silverwind.io> 1563741793 +0200
116
116
117
117
empty commit`, commitFromReader.Signature.Payload)
118
-
assert.EqualValues(t, "silverwind <me@silverwind.io>", commitFromReader.Author.String())
118
+
assert.Equal(t, "silverwind <me@silverwind.io>", commitFromReader.Author.String())
119
119
120
120
commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n\n"))
121
121
require.NoError(t, err)
122
122
commitFromReader.CommitMessage += "\n\n"
123
123
commitFromReader.Signature.Payload += "\n\n"
124
-
assert.EqualValues(t, commitFromReader, commitFromReader2)
124
+
assert.Equal(t, commitFromReader, commitFromReader2)
125
125
}
126
126
127
127
func TestCommitWithEncodingFromReader(t *testing.T) {
···
158
158
require.NoError(t, err)
159
159
require.NotNil(t, commitFromReader)
160
160
assert.EqualValues(t, sha, commitFromReader.ID)
161
-
assert.EqualValues(t, `-----BEGIN PGP SIGNATURE-----
161
+
assert.Equal(t, `-----BEGIN PGP SIGNATURE-----
162
162
163
163
iQGzBAABCgAdFiEE9HRrbqvYxPT8PXbefPSEkrowAa8FAmYGg7IACgkQfPSEkrow
164
164
Aa9olwv+P0HhtCM6CRvlUmPaqswRsDPNR4i66xyXGiSxdI9V5oJL7HLiQIM7KrFR
···
173
173
=r3UU
174
174
-----END PGP SIGNATURE-----
175
175
`, commitFromReader.Signature.Signature)
176
-
assert.EqualValues(t, `tree ca3fad42080dd1a6d291b75acdfc46e5b9b307e5
176
+
assert.Equal(t, `tree ca3fad42080dd1a6d291b75acdfc46e5b9b307e5
177
177
parent 47b24e7ab977ed31c5a39989d570847d6d0052af
178
178
author KN4CK3R <admin@oldschoolhack.me> 1711702962 +0100
179
179
committer KN4CK3R <admin@oldschoolhack.me> 1711702962 +0100
180
180
encoding ISO-8859-1
181
181
182
182
ISO-8859-1`, commitFromReader.Signature.Payload)
183
-
assert.EqualValues(t, "KN4CK3R <admin@oldschoolhack.me>", commitFromReader.Author.String())
183
+
assert.Equal(t, "KN4CK3R <admin@oldschoolhack.me>", commitFromReader.Author.String())
184
184
185
185
commitFromReader2, err := CommitFromReader(gitRepo, sha, strings.NewReader(commitString+"\n\n"))
186
186
require.NoError(t, err)
187
187
commitFromReader.CommitMessage += "\n\n"
188
188
commitFromReader.Signature.Payload += "\n\n"
189
-
assert.EqualValues(t, commitFromReader, commitFromReader2)
189
+
assert.Equal(t, commitFromReader, commitFromReader2)
190
190
}
191
191
192
192
func TestHasPreviousCommit(t *testing.T) {
+4
-4
modules/git/diff_test.go
+4
-4
modules/git/diff_test.go
···
162
162
163
163
func TestParseDiffHunkString(t *testing.T) {
164
164
leftLine, leftHunk, rightLine, rightHunk := ParseDiffHunkString("@@ -19,3 +19,5 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER")
165
-
assert.EqualValues(t, 19, leftLine)
166
-
assert.EqualValues(t, 3, leftHunk)
167
-
assert.EqualValues(t, 19, rightLine)
168
-
assert.EqualValues(t, 5, rightHunk)
165
+
assert.Equal(t, 19, leftLine)
166
+
assert.Equal(t, 3, leftHunk)
167
+
assert.Equal(t, 19, rightLine)
168
+
assert.Equal(t, 5, rightHunk)
169
169
}
+1
-4
modules/git/error.go
+1
-4
modules/git/error.go
+13
-10
modules/git/log_name_status.go
+13
-10
modules/git/log_name_status.go
···
118
118
g.buffull = false
119
119
g.next, err = g.rd.ReadSlice('\x00')
120
120
if err != nil {
121
-
if err == bufio.ErrBufferFull {
121
+
switch err {
122
+
case bufio.ErrBufferFull:
122
123
g.buffull = true
123
-
} else if err == io.EOF {
124
+
case io.EOF:
124
125
return nil, nil
125
-
} else {
126
+
default:
126
127
return nil, err
127
128
}
128
129
}
···
132
133
if bytes.Equal(g.next, []byte("commit\000")) {
133
134
g.next, err = g.rd.ReadSlice('\x00')
134
135
if err != nil {
135
-
if err == bufio.ErrBufferFull {
136
+
switch err {
137
+
case bufio.ErrBufferFull:
136
138
g.buffull = true
137
-
} else if err == io.EOF {
139
+
case io.EOF:
138
140
return nil, nil
139
-
} else {
141
+
default:
140
142
return nil, err
141
143
}
142
144
}
···
169
171
}
170
172
}
171
173
172
-
if err == io.EOF || !(g.next[0] == '\n' || g.next[0] == '\000') {
174
+
if err == io.EOF || (g.next[0] != '\n' && g.next[0] != '\000') {
173
175
return &ret, nil
174
176
}
175
177
···
214
216
}
215
217
g.next, err = g.rd.ReadSlice('\x00')
216
218
if err != nil {
217
-
if err == bufio.ErrBufferFull {
219
+
switch err {
220
+
case bufio.ErrBufferFull:
218
221
g.buffull = true
219
-
} else if err == io.EOF {
222
+
case io.EOF:
220
223
return &ret, nil
221
-
} else {
224
+
default:
222
225
return nil, err
223
226
}
224
227
}
+2
-2
modules/git/parse_test.go
+2
-2
modules/git/parse_test.go
···
57
57
require.NoError(t, err)
58
58
assert.Len(t, entries, len(testCase.Expected))
59
59
for i, entry := range entries {
60
-
assert.EqualValues(t, testCase.Expected[i], entry)
60
+
assert.Equal(t, testCase.Expected[i], entry)
61
61
}
62
62
}
63
63
}
···
90
90
require.NoError(t, err)
91
91
assert.Len(t, entries, len(testCase.Expected))
92
92
for i, entry := range entries {
93
-
assert.EqualValues(t, testCase.Expected[i], entry)
93
+
assert.Equal(t, testCase.Expected[i], entry)
94
94
}
95
95
}
96
96
}
+3
-3
modules/git/pushoptions/pushoptions_test.go
+3
-3
modules/git/pushoptions/pushoptions_test.go
···
22
22
options.Parse(fmt.Sprintf("%v", RepoPrivate))
23
23
actual := options.Map()
24
24
expected := map[string]string{string(RepoPrivate): "true"}
25
-
assert.EqualValues(t, expected, actual)
26
-
assert.EqualValues(t, expected, NewFromMap(&actual).Map())
25
+
assert.Equal(t, expected, actual)
26
+
assert.Equal(t, expected, NewFromMap(&actual).Map())
27
27
}
28
28
29
29
func TestChangeRepositorySettings(t *testing.T) {
···
46
46
47
47
val, ok := options.GetString(RepoPrivate)
48
48
assert.False(t, ok)
49
-
assert.Equal(t, "", val)
49
+
assert.Empty(t, val)
50
50
51
51
assert.True(t, options.GetBool(RepoPrivate, true))
52
52
assert.False(t, options.GetBool(RepoPrivate, false))
+8
-8
modules/git/repo_attribute_test.go
+8
-8
modules/git/repo_attribute_test.go
···
101
101
cloneStats, err := gitRepo.GitAttributes(commitID, "i-am-a-python.p", LinguistAttributes...)
102
102
require.NoError(t, err)
103
103
104
-
assert.EqualValues(t, cloneStats, bareStats)
104
+
assert.Equal(t, cloneStats, bareStats)
105
105
refStats := cloneStats
106
106
107
107
t.Run("GitAttributeChecker/"+commitID+"/SupportBare", func(t *testing.T) {
···
111
111
112
112
bareStats, err := bareChecker.CheckPath("i-am-a-python.p")
113
113
require.NoError(t, err)
114
-
assert.EqualValues(t, refStats, bareStats)
114
+
assert.Equal(t, refStats, bareStats)
115
115
})
116
116
t.Run("GitAttributeChecker/"+commitID+"/NoBareSupport", func(t *testing.T) {
117
117
defer test.MockVariableValue(&SupportCheckAttrOnBare, false)()
···
122
122
cloneStats, err := cloneChecker.CheckPath("i-am-a-python.p")
123
123
require.NoError(t, err)
124
124
125
-
assert.EqualValues(t, refStats, cloneStats)
125
+
assert.Equal(t, refStats, cloneStats)
126
126
})
127
127
}
128
128
}
···
135
135
136
136
attr, err := gitRepo.GitAttributes("8fee858da5796dfb37704761701bb8e800ad9ef3", "i-am-a-python.p", LinguistAttributes...)
137
137
require.NoError(t, err)
138
-
assert.EqualValues(t, map[string]GitAttribute{
138
+
assert.Equal(t, map[string]GitAttribute{
139
139
"gitlab-language": "unspecified",
140
140
"linguist-detectable": "unspecified",
141
141
"linguist-documentation": "unspecified",
···
146
146
147
147
attr, err = gitRepo.GitAttributes("341fca5b5ea3de596dc483e54c2db28633cd2f97", "i-am-a-python.p", LinguistAttributes...)
148
148
require.NoError(t, err)
149
-
assert.EqualValues(t, map[string]GitAttribute{
149
+
assert.Equal(t, map[string]GitAttribute{
150
150
"gitlab-language": "unspecified",
151
151
"linguist-detectable": "unspecified",
152
152
"linguist-documentation": "unspecified",
···
177
177
t.Run("none is specified", func(t *testing.T) {
178
178
language, err := gitRepo.GitAttributeFirst("8fee858da5796dfb37704761701bb8e800ad9ef3", "i-am-a-python.p", "linguist-detectable", "gitlab-language", "non-existing")
179
179
require.NoError(t, err)
180
-
assert.Equal(t, "", language.String())
180
+
assert.Empty(t, language.String())
181
181
})
182
182
}
183
183
184
184
func TestGitAttributeStruct(t *testing.T) {
185
-
assert.Equal(t, "", GitAttribute("").String())
186
-
assert.Equal(t, "", GitAttribute("unspecified").String())
185
+
assert.Empty(t, GitAttribute("").String())
186
+
assert.Empty(t, GitAttribute("unspecified").String())
187
187
188
188
assert.Equal(t, "python", GitAttribute("python").String())
189
189
+4
-4
modules/git/repo_base_test.go
+4
-4
modules/git/repo_base_test.go
···
45
45
sha, typ, size, err := ReadBatchLine(r)
46
46
require.NoError(t, err)
47
47
assert.Equal(t, "commit", typ)
48
-
assert.EqualValues(t, []byte("95bb4d39648ee7e325106df01a621c530863a653"), sha)
48
+
assert.Equal(t, []byte("95bb4d39648ee7e325106df01a621c530863a653"), sha)
49
49
assert.EqualValues(t, 144, size)
50
50
})
51
51
···
60
60
sha, typ, size, err := ReadBatchLine(r)
61
61
require.NoError(t, err)
62
62
assert.Equal(t, "commit", typ)
63
-
assert.EqualValues(t, []byte("95bb4d39648ee7e325106df01a621c530863a653"), sha)
63
+
assert.Equal(t, []byte("95bb4d39648ee7e325106df01a621c530863a653"), sha)
64
64
assert.EqualValues(t, 144, size)
65
65
})
66
66
···
120
120
sha, typ, size, err := ReadBatchLine(r)
121
121
require.NoError(t, err)
122
122
assert.Equal(t, "tag", typ)
123
-
assert.EqualValues(t, []byte("3ad28a9149a2864384548f3d17ed7f38014c9e8a"), sha)
123
+
assert.Equal(t, []byte("3ad28a9149a2864384548f3d17ed7f38014c9e8a"), sha)
124
124
assert.EqualValues(t, 807, size)
125
125
})
126
126
···
135
135
sha, typ, size, err := ReadBatchLine(r)
136
136
require.NoError(t, err)
137
137
assert.Equal(t, "tag", typ)
138
-
assert.EqualValues(t, []byte("3ad28a9149a2864384548f3d17ed7f38014c9e8a"), sha)
138
+
assert.Equal(t, []byte("3ad28a9149a2864384548f3d17ed7f38014c9e8a"), sha)
139
139
assert.EqualValues(t, 807, size)
140
140
})
141
141
+6
-6
modules/git/repo_branch_test.go
+6
-6
modules/git/repo_branch_test.go
···
21
21
22
22
require.NoError(t, err)
23
23
assert.Len(t, branches, 2)
24
-
assert.EqualValues(t, 3, countAll)
24
+
assert.Equal(t, 3, countAll)
25
25
assert.ElementsMatch(t, []string{"master", "branch2"}, branches)
26
26
27
27
branches, countAll, err = bareRepo1.GetBranchNames(0, 0)
28
28
29
29
require.NoError(t, err)
30
30
assert.Len(t, branches, 3)
31
-
assert.EqualValues(t, 3, countAll)
31
+
assert.Equal(t, 3, countAll)
32
32
assert.ElementsMatch(t, []string{"master", "branch2", "branch1"}, branches)
33
33
34
34
branches, countAll, err = bareRepo1.GetBranchNames(5, 1)
35
35
36
36
require.NoError(t, err)
37
37
assert.Empty(t, branches)
38
-
assert.EqualValues(t, 3, countAll)
38
+
assert.Equal(t, 3, countAll)
39
39
assert.ElementsMatch(t, []string{}, branches)
40
40
}
41
41
···
71
71
// refs/pull/1/head
72
72
branches, err = bareRepo5.GetRefsBySha("c83380d7056593c51a699d12b9c00627bd5743e9", PullPrefix)
73
73
require.NoError(t, err)
74
-
assert.EqualValues(t, []string{"refs/pull/1/head"}, branches)
74
+
assert.Equal(t, []string{"refs/pull/1/head"}, branches)
75
75
76
76
branches, err = bareRepo5.GetRefsBySha("d8e0bbb45f200e67d9a784ce55bd90821af45ebd", BranchPrefix)
77
77
require.NoError(t, err)
78
-
assert.EqualValues(t, []string{"refs/heads/master", "refs/heads/master-clone"}, branches)
78
+
assert.Equal(t, []string{"refs/heads/master", "refs/heads/master-clone"}, branches)
79
79
80
80
branches, err = bareRepo5.GetRefsBySha("58a4bcc53ac13e7ff76127e0fb518b5262bf09af", BranchPrefix)
81
81
require.NoError(t, err)
82
-
assert.EqualValues(t, []string{"refs/heads/test-patch-1"}, branches)
82
+
assert.Equal(t, []string{"refs/heads/test-patch-1"}, branches)
83
83
}
84
84
85
85
func BenchmarkGetRefsBySha(b *testing.B) {
+4
-4
modules/git/repo_commit_test.go
+4
-4
modules/git/repo_commit_test.go
···
127
127
128
128
aTagID, err := bareRepo1.GetTagCommitID(aTagName)
129
129
require.NoError(t, err)
130
-
assert.NotEqualValues(t, aTagCommitID, aTagID)
130
+
assert.NotEqual(t, aTagCommitID, aTagID)
131
131
132
132
lTagID, err := bareRepo1.GetTagCommitID(lTagName)
133
133
require.NoError(t, err)
134
-
assert.EqualValues(t, lTagCommitID, lTagID)
134
+
assert.Equal(t, lTagCommitID, lTagID)
135
135
136
136
aTag, err := bareRepo1.GetTagCommit(aTagName)
137
137
require.NoError(t, err)
138
-
assert.EqualValues(t, aTagCommitID, aTag.ID.String())
138
+
assert.Equal(t, aTagCommitID, aTag.ID.String())
139
139
140
140
lTag, err := bareRepo1.GetTagCommit(lTagName)
141
141
require.NoError(t, err)
142
-
assert.EqualValues(t, lTagCommitID, lTag.ID.String())
142
+
assert.Equal(t, lTagCommitID, lTag.ID.String())
143
143
}
144
144
145
145
func TestCommitsByRange(t *testing.T) {
+1
-1
modules/git/repo_language_stats.go
+1
-1
modules/git/repo_language_stats.go
···
234
234
sizes[language] += f.Size()
235
235
} else if len(sizes) == 0 && (firstExcludedLanguage == "" || firstExcludedLanguage == language) {
236
236
// Only consider Programming or Markup languages as fallback
237
-
if !(langType == enry.Programming || langType == enry.Markup) {
237
+
if langType != enry.Programming && langType != enry.Markup {
238
238
continue
239
239
}
240
240
firstExcludedLanguage = language
+2
-2
modules/git/repo_language_stats_test.go
+2
-2
modules/git/repo_language_stats_test.go
···
21
21
stats, err := gitRepo.GetLanguageStats("8fee858da5796dfb37704761701bb8e800ad9ef3")
22
22
require.NoError(t, err)
23
23
24
-
assert.EqualValues(t, map[string]int64{
24
+
assert.Equal(t, map[string]int64{
25
25
"Python": 134,
26
26
"Java": 112,
27
27
}, stats)
28
28
}
29
29
30
30
func TestMergeLanguageStats(t *testing.T) {
31
-
assert.EqualValues(t, map[string]int64{
31
+
assert.Equal(t, map[string]int64{
32
32
"PHP": 1,
33
33
"python": 10,
34
34
"JAVA": 700,
+4
-3
modules/git/repo_ref.go
+4
-3
modules/git/repo_ref.go
···
22
22
// refType should only be a literal "branch" or "tag" and nothing else
23
23
func (repo *Repository) ListOccurrences(ctx context.Context, refType, commitSHA string) ([]string, error) {
24
24
cmd := NewCommand(ctx)
25
-
if refType == "branch" {
25
+
switch refType {
26
+
case "branch":
26
27
cmd.AddArguments("branch")
27
-
} else if refType == "tag" {
28
+
case "tag":
28
29
cmd.AddArguments("tag")
29
-
} else {
30
+
default:
30
31
return nil, util.NewInvalidArgumentErrorf(`can only use "branch" or "tag" for refType, but got %q`, refType)
31
32
}
32
33
stdout, _, err := cmd.AddArguments("--no-color", "--sort=-creatordate", "--contains").AddDynamicArguments(commitSHA).RunStdString(&RunOpts{Dir: repo.Path})
+1
-1
modules/git/repo_stats_test.go
+1
-1
modules/git/repo_stats_test.go
···
31
31
assert.EqualValues(t, 10, code.Additions)
32
32
assert.EqualValues(t, 1, code.Deletions)
33
33
assert.Len(t, code.Authors, 3)
34
-
assert.EqualValues(t, "tris.git@shoddynet.org", code.Authors[1].Email)
34
+
assert.Equal(t, "tris.git@shoddynet.org", code.Authors[1].Email)
35
35
assert.EqualValues(t, 3, code.Authors[1].Commits)
36
36
assert.EqualValues(t, 5, code.Authors[0].Commits)
37
37
}
+33
-69
modules/git/repo_tag_test.go
+33
-69
modules/git/repo_tag_test.go
···
28
28
}
29
29
assert.Len(t, tags, 2)
30
30
assert.Len(t, tags, total)
31
-
assert.EqualValues(t, "signed-tag", tags[0].Name)
32
-
assert.EqualValues(t, "36f97d9a96457e2bab511db30fe2db03893ebc64", tags[0].ID.String())
33
-
assert.EqualValues(t, "tag", tags[0].Type)
34
-
assert.EqualValues(t, time.Date(2022, time.November, 13, 16, 40, 20, 0, time.FixedZone("", 3600)), tags[0].Tagger.When)
35
-
assert.EqualValues(t, "test", tags[1].Name)
36
-
assert.EqualValues(t, "3ad28a9149a2864384548f3d17ed7f38014c9e8a", tags[1].ID.String())
37
-
assert.EqualValues(t, "tag", tags[1].Type)
38
-
assert.EqualValues(t, time.Date(2018, time.June, 16, 20, 13, 18, 0, time.FixedZone("", -25200)), tags[1].Tagger.When)
31
+
assert.Equal(t, "signed-tag", tags[0].Name)
32
+
assert.Equal(t, "36f97d9a96457e2bab511db30fe2db03893ebc64", tags[0].ID.String())
33
+
assert.Equal(t, "tag", tags[0].Type)
34
+
assert.Equal(t, time.Date(2022, time.November, 13, 16, 40, 20, 0, time.FixedZone("", 3600)), tags[0].Tagger.When)
35
+
assert.Equal(t, "test", tags[1].Name)
36
+
assert.Equal(t, "3ad28a9149a2864384548f3d17ed7f38014c9e8a", tags[1].ID.String())
37
+
assert.Equal(t, "tag", tags[1].Type)
38
+
assert.Equal(t, time.Date(2018, time.June, 16, 20, 13, 18, 0, time.FixedZone("", -25200)), tags[1].Tagger.When)
39
39
}
40
40
41
41
func TestRepository_GetTag(t *testing.T) {
42
42
bareRepo1Path := filepath.Join(testReposDir, "repo1_bare")
43
43
44
44
clonedPath, err := cloneRepo(t, bareRepo1Path)
45
-
if err != nil {
46
-
require.NoError(t, err)
47
-
return
48
-
}
45
+
require.NoError(t, err)
49
46
50
47
bareRepo1, err := openRepositoryWithDefaultContext(clonedPath)
51
-
if err != nil {
52
-
require.NoError(t, err)
53
-
return
54
-
}
48
+
require.NoError(t, err)
55
49
defer bareRepo1.Close()
56
50
57
51
// LIGHTWEIGHT TAGS
···
60
54
61
55
// Create the lightweight tag
62
56
err = bareRepo1.CreateTag(lTagName, lTagCommitID)
63
-
if err != nil {
64
-
require.NoError(t, err, "Unable to create the lightweight tag: %s for ID: %s. Error: %v", lTagName, lTagCommitID, err)
65
-
return
66
-
}
57
+
require.NoError(t, err, "Unable to create the lightweight tag: %s for ID: %s. Error: %v", lTagName, lTagCommitID, err)
67
58
68
59
// and try to get the Tag for lightweight tag
69
60
lTag, err := bareRepo1.GetTag(lTagName)
70
-
if err != nil {
71
-
require.NoError(t, err)
72
-
return
73
-
}
74
-
if lTag == nil {
75
-
assert.NotNil(t, lTag)
76
-
assert.FailNow(t, "nil lTag: %s", lTagName)
77
-
}
78
-
assert.EqualValues(t, lTagName, lTag.Name)
79
-
assert.EqualValues(t, lTagCommitID, lTag.ID.String())
80
-
assert.EqualValues(t, lTagCommitID, lTag.Object.String())
81
-
assert.EqualValues(t, "commit", lTag.Type)
61
+
require.NoError(t, err)
62
+
require.NotNil(t, lTag)
63
+
assert.Equal(t, lTagName, lTag.Name)
64
+
assert.Equal(t, lTagCommitID, lTag.ID.String())
65
+
assert.Equal(t, lTagCommitID, lTag.Object.String())
66
+
assert.Equal(t, "commit", lTag.Type)
82
67
83
68
// ANNOTATED TAGS
84
69
aTagCommitID := "8006ff9adbf0cb94da7dad9e537e53817f9fa5c0"
···
87
72
88
73
// Create the annotated tag
89
74
err = bareRepo1.CreateAnnotatedTag(aTagName, aTagMessage, aTagCommitID)
90
-
if err != nil {
91
-
require.NoError(t, err, "Unable to create the annotated tag: %s for ID: %s. Error: %v", aTagName, aTagCommitID, err)
92
-
return
93
-
}
75
+
require.NoError(t, err, "Unable to create the annotated tag: %s for ID: %s. Error: %v", aTagName, aTagCommitID, err)
94
76
95
77
// Now try to get the tag for the annotated Tag
96
78
aTagID, err := bareRepo1.GetTagID(aTagName)
97
-
if err != nil {
98
-
require.NoError(t, err)
99
-
return
100
-
}
79
+
require.NoError(t, err)
101
80
102
81
aTag, err := bareRepo1.GetTag(aTagName)
103
-
if err != nil {
104
-
require.NoError(t, err)
105
-
return
106
-
}
107
-
if aTag == nil {
108
-
assert.NotNil(t, aTag)
109
-
assert.FailNow(t, "nil aTag: %s", aTagName)
110
-
}
111
-
assert.EqualValues(t, aTagName, aTag.Name)
112
-
assert.EqualValues(t, aTagID, aTag.ID.String())
82
+
require.NoError(t, err)
83
+
require.NotNil(t, aTag)
84
+
assert.Equal(t, aTagName, aTag.Name)
85
+
assert.Equal(t, aTagID, aTag.ID.String())
113
86
assert.NotEqual(t, aTagID, aTag.Object.String())
114
-
assert.EqualValues(t, aTagCommitID, aTag.Object.String())
115
-
assert.EqualValues(t, "tag", aTag.Type)
87
+
assert.Equal(t, aTagCommitID, aTag.Object.String())
88
+
assert.Equal(t, "tag", aTag.Type)
116
89
117
90
// RELEASE TAGS
118
91
···
120
93
rTagName := "release/" + lTagName
121
94
122
95
err = bareRepo1.CreateTag(rTagName, rTagCommitID)
123
-
if err != nil {
124
-
require.NoError(t, err, "Unable to create the tag: %s for ID: %s. Error: %v", rTagName, rTagCommitID, err)
125
-
return
126
-
}
96
+
require.NoError(t, err, "Unable to create the tag: %s for ID: %s. Error: %v", rTagName, rTagCommitID, err)
127
97
128
98
rTagID, err := bareRepo1.GetTagID(rTagName)
129
-
if err != nil {
130
-
require.NoError(t, err)
131
-
return
132
-
}
133
-
assert.EqualValues(t, rTagCommitID, rTagID)
99
+
require.NoError(t, err)
100
+
assert.Equal(t, rTagCommitID, rTagID)
134
101
135
102
oTagID, err := bareRepo1.GetTagID(lTagName)
136
-
if err != nil {
137
-
require.NoError(t, err)
138
-
return
139
-
}
140
-
assert.EqualValues(t, lTagCommitID, oTagID)
103
+
require.NoError(t, err)
104
+
assert.Equal(t, lTagCommitID, oTagID)
141
105
}
142
106
143
107
func TestRepository_GetAnnotatedTag(t *testing.T) {
···
173
137
return
174
138
}
175
139
assert.NotNil(t, tag)
176
-
assert.EqualValues(t, aTagName, tag.Name)
177
-
assert.EqualValues(t, aTagID, tag.ID.String())
178
-
assert.EqualValues(t, "tag", tag.Type)
140
+
assert.Equal(t, aTagName, tag.Name)
141
+
assert.Equal(t, aTagID, tag.ID.String())
142
+
assert.Equal(t, "tag", tag.Type)
179
143
180
144
// Annotated tag's Commit ID should fail
181
145
tag2, err := bareRepo1.GetAnnotatedTag(aTagCommitID)
+2
-2
modules/git/repo_tree.go
+2
-2
modules/git/repo_tree.go
···
97
97
if err != nil {
98
98
return nil, err
99
99
}
100
-
commit.Tree.ResolvedID = resolvedID
100
+
commit.ResolvedID = resolvedID
101
101
return &commit.Tree, nil
102
102
case "commit":
103
103
commit, err := CommitFromReader(repo, id, io.LimitReader(rd, size))
···
107
107
if _, err := rd.Discard(1); err != nil {
108
108
return nil, err
109
109
}
110
-
commit.Tree.ResolvedID = commit.ID
110
+
commit.ResolvedID = commit.ID
111
111
return &commit.Tree, nil
112
112
case "tree":
113
113
tree := NewTree(repo, id)
+1
-1
modules/git/signature_test.go
+1
-1
modules/git/signature_test.go
+1
-1
modules/git/submodule_test.go
+1
-1
modules/git/submodule_test.go
+10
-10
modules/git/tag_test.go
+10
-10
modules/git/tag_test.go
···
87
87
for _, test := range testData {
88
88
tag, err := parseTagData(Sha1ObjectFormat, test.data)
89
89
require.NoError(t, err)
90
-
assert.EqualValues(t, test.tag.ID, tag.ID)
91
-
assert.EqualValues(t, test.tag.Object, tag.Object)
92
-
assert.EqualValues(t, test.tag.Name, tag.Name)
93
-
assert.EqualValues(t, test.tag.Message, tag.Message)
94
-
assert.EqualValues(t, test.tag.Type, tag.Type)
90
+
assert.Equal(t, test.tag.ID, tag.ID)
91
+
assert.Equal(t, test.tag.Object, tag.Object)
92
+
assert.Equal(t, test.tag.Name, tag.Name)
93
+
assert.Equal(t, test.tag.Message, tag.Message)
94
+
assert.Equal(t, test.tag.Type, tag.Type)
95
95
if test.tag.Signature != nil && assert.NotNil(t, tag.Signature) {
96
-
assert.EqualValues(t, test.tag.Signature.Signature, tag.Signature.Signature)
97
-
assert.EqualValues(t, test.tag.Signature.Payload, tag.Signature.Payload)
96
+
assert.Equal(t, test.tag.Signature.Signature, tag.Signature.Signature)
97
+
assert.Equal(t, test.tag.Signature.Payload, tag.Signature.Payload)
98
98
} else {
99
99
assert.Nil(t, tag.Signature)
100
100
}
101
101
if test.tag.Tagger != nil && assert.NotNil(t, tag.Tagger) {
102
-
assert.EqualValues(t, test.tag.Tagger.Name, tag.Tagger.Name)
103
-
assert.EqualValues(t, test.tag.Tagger.Email, tag.Tagger.Email)
104
-
assert.EqualValues(t, test.tag.Tagger.When.Unix(), tag.Tagger.When.Unix())
102
+
assert.Equal(t, test.tag.Tagger.Name, tag.Tagger.Name)
103
+
assert.Equal(t, test.tag.Tagger.Email, tag.Tagger.Email)
104
+
assert.Equal(t, test.tag.Tagger.When.Unix(), tag.Tagger.When.Unix())
105
105
} else {
106
106
assert.Nil(t, tag.Tagger)
107
107
}
+2
-2
modules/git/tree_test.go
+2
-2
modules/git/tree_test.go
···
34
34
35
35
commitID, err := repo.GetBranchCommitID("master")
36
36
require.NoError(t, err)
37
-
assert.EqualValues(t, "544d8f7a3b15927cddf2299b4b562d6ebd71b6a7", commitID)
37
+
assert.Equal(t, "544d8f7a3b15927cddf2299b4b562d6ebd71b6a7", commitID)
38
38
39
39
commit, err := repo.GetTreePathLatestCommit("master", "blame.txt")
40
40
require.NoError(t, err)
41
41
assert.NotNil(t, commit)
42
-
assert.EqualValues(t, "45fb6cbc12f970b04eacd5cd4165edd11c8d7376", commit.ID.String())
42
+
assert.Equal(t, "45fb6cbc12f970b04eacd5cd4165edd11c8d7376", commit.ID.String())
43
43
}
+2
-2
modules/git/url/url_test.go
+2
-2
modules/git/url/url_test.go
···
160
160
t.Run(kase.kase, func(t *testing.T) {
161
161
u, err := Parse(kase.kase)
162
162
require.NoError(t, err)
163
-
assert.EqualValues(t, kase.expected.extraMark, u.extraMark)
164
-
assert.EqualValues(t, *kase.expected, *u)
163
+
assert.Equal(t, kase.expected.extraMark, u.extraMark)
164
+
assert.Equal(t, *kase.expected, *u)
165
165
})
166
166
}
167
167
}
+6
-6
modules/graceful/releasereopen/releasereopen_test.go
+6
-6
modules/graceful/releasereopen/releasereopen_test.go
···
31
31
_ = m.Register(t3)
32
32
33
33
require.NoError(t, m.ReleaseReopen())
34
-
assert.EqualValues(t, 1, t1.count)
35
-
assert.EqualValues(t, 1, t2.count)
36
-
assert.EqualValues(t, 1, t3.count)
34
+
assert.Equal(t, 1, t1.count)
35
+
assert.Equal(t, 1, t2.count)
36
+
assert.Equal(t, 1, t3.count)
37
37
38
38
c2()
39
39
40
40
require.NoError(t, m.ReleaseReopen())
41
-
assert.EqualValues(t, 2, t1.count)
42
-
assert.EqualValues(t, 1, t2.count)
43
-
assert.EqualValues(t, 2, t3.count)
41
+
assert.Equal(t, 2, t1.count)
42
+
assert.Equal(t, 1, t2.count)
43
+
assert.Equal(t, 2, t3.count)
44
44
}
+1
-1
modules/graceful/server.go
+1
-1
modules/graceful/server.go
+1
-4
modules/graceful/server_hooks.go
+1
-4
modules/graceful/server_hooks.go
+2
-2
modules/highlight/highlight_test.go
+2
-2
modules/highlight/highlight_test.go
···
133
133
t.Run(tt.name, func(t *testing.T) {
134
134
out, lexerName, err := File(tt.name, "", []byte(tt.code))
135
135
require.NoError(t, err)
136
-
assert.EqualValues(t, tt.want, out)
136
+
assert.Equal(t, tt.want, out)
137
137
assert.Equal(t, tt.lexerName, lexerName)
138
138
})
139
139
}
···
196
196
for _, tt := range tests {
197
197
t.Run(tt.name, func(t *testing.T) {
198
198
out := PlainText([]byte(tt.code))
199
-
assert.EqualValues(t, tt.want, out)
199
+
assert.Equal(t, tt.want, out)
200
200
})
201
201
}
202
202
}
+2
-2
modules/indexer/code/elasticsearch/elasticsearch_test.go
+2
-2
modules/indexer/code/elasticsearch/elasticsearch_test.go
+4
-4
modules/indexer/code/indexer_test.go
+4
-4
modules/indexer/code/indexer_test.go
···
110
110
ids := make([]int64, 0, len(res))
111
111
for _, hit := range res {
112
112
ids = append(ids, hit.RepoID)
113
-
assert.EqualValues(t, "# repo1\n\nDescription for repo1", hit.Content)
113
+
assert.Equal(t, "# repo1\n\nDescription for repo1", hit.Content)
114
114
}
115
-
assert.EqualValues(t, kw.IDs, ids)
115
+
assert.Equal(t, kw.IDs, ids)
116
116
})
117
117
}
118
118
···
131
131
if idx != nil {
132
132
idx.Close()
133
133
}
134
-
assert.FailNow(t, "Unable to create bleve indexer Error: %v", err)
134
+
require.NoError(t, err)
135
135
}
136
136
defer idx.Close()
137
137
···
152
152
if indexer != nil {
153
153
indexer.Close()
154
154
}
155
-
assert.FailNow(t, "Unable to init ES indexer Error: %v", err)
155
+
assert.FailNow(t, "Unable to init ES indexer", "error: %v", err)
156
156
}
157
157
158
158
defer indexer.Close()
+1
-1
modules/indexer/internal/bleve/metadata_test.go
+1
-1
modules/indexer/internal/bleve/metadata_test.go
+10
-10
modules/indexer/issues/internal/tests/tests.go
+10
-10
modules/indexer/issues/internal/tests/tests.go
···
93
93
Name: "default",
94
94
SearchOptions: &internal.SearchOptions{},
95
95
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
96
-
assert.Equal(t, len(data), len(result.Hits))
96
+
assert.Len(t, result.Hits, len(data))
97
97
assert.Equal(t, len(data), int(result.Total))
98
98
},
99
99
},
···
557
557
SortBy: internal.SortByCreatedDesc,
558
558
},
559
559
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
560
-
assert.Equal(t, len(data), len(result.Hits))
560
+
assert.Len(t, result.Hits, len(data))
561
561
assert.Equal(t, len(data), int(result.Total))
562
562
for i, v := range result.Hits {
563
563
if i < len(result.Hits)-1 {
···
573
573
SortBy: internal.SortByUpdatedDesc,
574
574
},
575
575
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
576
-
assert.Equal(t, len(data), len(result.Hits))
576
+
assert.Len(t, result.Hits, len(data))
577
577
assert.Equal(t, len(data), int(result.Total))
578
578
for i, v := range result.Hits {
579
579
if i < len(result.Hits)-1 {
···
589
589
SortBy: internal.SortByCommentsDesc,
590
590
},
591
591
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
592
-
assert.Equal(t, len(data), len(result.Hits))
592
+
assert.Len(t, result.Hits, len(data))
593
593
assert.Equal(t, len(data), int(result.Total))
594
594
for i, v := range result.Hits {
595
595
if i < len(result.Hits)-1 {
···
605
605
SortBy: internal.SortByDeadlineDesc,
606
606
},
607
607
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
608
-
assert.Equal(t, len(data), len(result.Hits))
608
+
assert.Len(t, result.Hits, len(data))
609
609
assert.Equal(t, len(data), int(result.Total))
610
610
for i, v := range result.Hits {
611
611
if i < len(result.Hits)-1 {
···
621
621
SortBy: internal.SortByScore,
622
622
},
623
623
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
624
-
assert.Equal(t, len(data), len(result.Hits))
624
+
assert.Len(t, result.Hits, len(data))
625
625
assert.Equal(t, len(data), int(result.Total))
626
626
for i, v := range result.Hits {
627
627
if i < len(result.Hits)-1 {
···
637
637
SortBy: internal.SortByCreatedAsc,
638
638
},
639
639
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
640
-
assert.Equal(t, len(data), len(result.Hits))
640
+
assert.Len(t, result.Hits, len(data))
641
641
assert.Equal(t, len(data), int(result.Total))
642
642
for i, v := range result.Hits {
643
643
if i < len(result.Hits)-1 {
···
653
653
SortBy: internal.SortByUpdatedAsc,
654
654
},
655
655
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
656
-
assert.Equal(t, len(data), len(result.Hits))
656
+
assert.Len(t, result.Hits, len(data))
657
657
assert.Equal(t, len(data), int(result.Total))
658
658
for i, v := range result.Hits {
659
659
if i < len(result.Hits)-1 {
···
669
669
SortBy: internal.SortByCommentsAsc,
670
670
},
671
671
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
672
-
assert.Equal(t, len(data), len(result.Hits))
672
+
assert.Len(t, result.Hits, len(data))
673
673
assert.Equal(t, len(data), int(result.Total))
674
674
for i, v := range result.Hits {
675
675
if i < len(result.Hits)-1 {
···
685
685
SortBy: internal.SortByDeadlineAsc,
686
686
},
687
687
Expected: func(t *testing.T, data map[int64]*internal.IndexerData, result *internal.SearchResult) {
688
-
assert.Equal(t, len(data), len(result.Hits))
688
+
assert.Len(t, result.Hits, len(data))
689
689
assert.Equal(t, len(data), int(result.Total))
690
690
for i, v := range result.Hits {
691
691
if i < len(result.Hits)-1 {
+6
-6
modules/indexer/issues/meilisearch/meilisearch_test.go
+6
-6
modules/indexer/issues/meilisearch/meilisearch_test.go
···
85
85
}
86
86
hits, err := convertHits(validResponse)
87
87
require.NoError(t, err)
88
-
assert.EqualValues(t, []internal.Match{{ID: 11}, {ID: 22}, {ID: 33}}, hits)
88
+
assert.Equal(t, []internal.Match{{ID: 11}, {ID: 22}, {ID: 33}}, hits)
89
89
}
90
90
91
91
func TestDoubleQuoteKeyword(t *testing.T) {
92
-
assert.EqualValues(t, "", doubleQuoteKeyword(""))
93
-
assert.EqualValues(t, `"a" "b" "c"`, doubleQuoteKeyword("a b c"))
94
-
assert.EqualValues(t, `"a" "d" "g"`, doubleQuoteKeyword("a d g"))
95
-
assert.EqualValues(t, `"a" "d" "g"`, doubleQuoteKeyword("a d g"))
96
-
assert.EqualValues(t, `"a" "d" "g"`, doubleQuoteKeyword(`a "" "d" """g`))
92
+
assert.Empty(t, doubleQuoteKeyword(""))
93
+
assert.Equal(t, `"a" "b" "c"`, doubleQuoteKeyword("a b c"))
94
+
assert.Equal(t, `"a" "d" "g"`, doubleQuoteKeyword("a d g"))
95
+
assert.Equal(t, `"a" "d" "g"`, doubleQuoteKeyword("a d g"))
96
+
assert.Equal(t, `"a" "d" "g"`, doubleQuoteKeyword(`a "" "d" """g`))
97
97
}
+1
-1
modules/issue/template/template.go
+1
-1
modules/issue/template/template.go
···
191
191
}
192
192
for _, visibleType := range visibilityList {
193
193
visibleType, ok := visibleType.(string)
194
-
if !ok || !(visibleType == "form" || visibleType == "content") {
194
+
if !ok || (visibleType != "form" && visibleType != "content") {
195
195
return position.Errorf("'visible' list can only contain strings of 'form' and 'content'")
196
196
}
197
197
}
+1
-1
modules/issue/template/template_test.go
+1
-1
modules/issue/template/template_test.go
+12
-12
modules/keying/keying_test.go
+12
-12
modules/keying/keying_test.go
···
50
50
cipherText2 := key.Encrypt(plainText, []byte{0x05, 0x06})
51
51
52
52
// Ensure ciphertexts don't have an deterministic output.
53
-
assert.NotEqualValues(t, cipherText, cipherText2)
53
+
assert.NotEqual(t, cipherText, cipherText2)
54
54
})
55
55
56
56
t.Run("Decrypt", func(t *testing.T) {
···
59
59
t.Run("Successful", func(t *testing.T) {
60
60
convertedPlainText, err := key.Decrypt(cipherText, []byte{0x05, 0x06})
61
61
require.NoError(t, err)
62
-
assert.EqualValues(t, plainText, convertedPlainText)
62
+
assert.Equal(t, plainText, convertedPlainText)
63
63
})
64
64
65
65
t.Run("Not enough additional data", func(t *testing.T) {
···
97
97
}
98
98
99
99
func TestKeyingColumnAndID(t *testing.T) {
100
-
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table", math.MinInt64))
101
-
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table", -1))
102
-
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table", 0))
103
-
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, keying.ColumnAndID("table", 1))
104
-
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table", math.MaxInt64))
100
+
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table", math.MinInt64))
101
+
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table", -1))
102
+
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table", 0))
103
+
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, keying.ColumnAndID("table", 1))
104
+
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x3a, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table", math.MaxInt64))
105
105
106
-
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table2", math.MinInt64))
107
-
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table2", -1))
108
-
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table2", 0))
109
-
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, keying.ColumnAndID("table2", 1))
110
-
assert.EqualValues(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table2", math.MaxInt64))
106
+
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table2", math.MinInt64))
107
+
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table2", -1))
108
+
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, keying.ColumnAndID("table2", 0))
109
+
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01}, keying.ColumnAndID("table2", 1))
110
+
assert.Equal(t, []byte{0x74, 0x61, 0x62, 0x6c, 0x65, 0x32, 0x3a, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}, keying.ColumnAndID("table2", math.MaxInt64))
111
111
}
+2
-2
modules/lfs/content_store.go
+2
-2
modules/lfs/content_store.go
···
79
79
80
80
// Exists returns true if the object exists in the content store.
81
81
func (s *ContentStore) Exists(pointer Pointer) (bool, error) {
82
-
_, err := s.ObjectStorage.Stat(pointer.RelativePath())
82
+
_, err := s.Stat(pointer.RelativePath())
83
83
if err != nil {
84
84
if os.IsNotExist(err) {
85
85
return false, nil
···
92
92
// Verify returns true if the object exists in the content store and size is correct.
93
93
func (s *ContentStore) Verify(pointer Pointer) (bool, error) {
94
94
p := pointer.RelativePath()
95
-
fi, err := s.ObjectStorage.Stat(p)
95
+
fi, err := s.Stat(p)
96
96
if os.IsNotExist(err) || (err == nil && fi.Size() != pointer.Size) {
97
97
return false, nil
98
98
} else if err != nil {
+1
-1
modules/log/event_writer_base.go
+1
-1
modules/log/event_writer_base.go
···
105
105
case io.WriterTo:
106
106
_, err = msg.WriteTo(b.OutputWriteCloser)
107
107
default:
108
-
_, err = b.OutputWriteCloser.Write([]byte(fmt.Sprint(msg)))
108
+
_, err = fmt.Fprint(b.OutputWriteCloser, msg)
109
109
}
110
110
if err != nil {
111
111
FallbackErrorf("unable to write log message of %q (%v): %v", b.Name, err, event.Msg)
+7
-7
modules/log/flags_test.go
+7
-7
modules/log/flags_test.go
···
13
13
)
14
14
15
15
func TestFlags(t *testing.T) {
16
-
assert.EqualValues(t, Ldefault, Flags{}.Bits())
16
+
assert.Equal(t, Ldefault, Flags{}.Bits())
17
17
assert.EqualValues(t, 0, FlagsFromString("").Bits())
18
-
assert.EqualValues(t, Lgopid, FlagsFromString("", Lgopid).Bits())
18
+
assert.Equal(t, Lgopid, FlagsFromString("", Lgopid).Bits())
19
19
assert.EqualValues(t, 0, FlagsFromString("none", Lgopid).Bits())
20
-
assert.EqualValues(t, Ldate|Ltime, FlagsFromString("date,time", Lgopid).Bits())
20
+
assert.Equal(t, Ldate|Ltime, FlagsFromString("date,time", Lgopid).Bits())
21
21
22
-
assert.EqualValues(t, "stdflags", FlagsFromString("stdflags").String())
23
-
assert.EqualValues(t, "medfile", FlagsFromString("medfile").String())
22
+
assert.Equal(t, "stdflags", FlagsFromString("stdflags").String())
23
+
assert.Equal(t, "medfile", FlagsFromString("medfile").String())
24
24
25
25
bs, err := json.Marshal(FlagsFromString("utc,level"))
26
26
require.NoError(t, err)
27
-
assert.EqualValues(t, `"level,utc"`, string(bs))
27
+
assert.Equal(t, `"level,utc"`, string(bs))
28
28
var flags Flags
29
29
require.NoError(t, json.Unmarshal(bs, &flags))
30
-
assert.EqualValues(t, LUTC|Llevel, flags.Bits())
30
+
assert.Equal(t, LUTC|Llevel, flags.Bits())
31
31
}
+3
-3
modules/log/groutinelabel_test.go
+3
-3
modules/log/groutinelabel_test.go
···
15
15
pprof.Do(t.Context(), pprof.Labels(), func(ctx context.Context) {
16
16
currentLabels := getGoroutineLabels()
17
17
pprof.ForLabels(ctx, func(key, value string) bool {
18
-
assert.EqualValues(t, value, currentLabels[key])
18
+
assert.Equal(t, value, currentLabels[key])
19
19
return true
20
20
})
21
21
22
22
pprof.Do(ctx, pprof.Labels("Test_getGoroutineLabels", "Test_getGoroutineLabels_child1"), func(ctx context.Context) {
23
23
currentLabels := getGoroutineLabels()
24
24
pprof.ForLabels(ctx, func(key, value string) bool {
25
-
assert.EqualValues(t, value, currentLabels[key])
25
+
assert.Equal(t, value, currentLabels[key])
26
26
return true
27
27
})
28
28
if assert.NotNil(t, currentLabels) {
29
-
assert.EqualValues(t, "Test_getGoroutineLabels_child1", currentLabels["Test_getGoroutineLabels"])
29
+
assert.Equal(t, "Test_getGoroutineLabels_child1", currentLabels["Test_getGoroutineLabels"])
30
30
}
31
31
})
32
32
})
+3
-3
modules/log/logger_test.go
+3
-3
modules/log/logger_test.go
···
56
56
57
57
dump := logger.DumpWriters()
58
58
assert.Empty(t, dump)
59
-
assert.EqualValues(t, NONE, logger.GetLevel())
59
+
assert.Equal(t, NONE, logger.GetLevel())
60
60
assert.False(t, logger.IsEnabled())
61
61
62
62
w1 := newDummyWriter("dummy-1", DEBUG, 0)
63
63
logger.AddWriters(w1)
64
-
assert.EqualValues(t, DEBUG, logger.GetLevel())
64
+
assert.Equal(t, DEBUG, logger.GetLevel())
65
65
66
66
w2 := newDummyWriter("dummy-2", WARN, 200*time.Millisecond)
67
67
logger.AddWriters(w2)
68
-
assert.EqualValues(t, DEBUG, logger.GetLevel())
68
+
assert.Equal(t, DEBUG, logger.GetLevel())
69
69
70
70
dump = logger.DumpWriters()
71
71
assert.Len(t, dump, 2)
+1
-1
modules/markup/common/footnote.go
+1
-1
modules/markup/common/footnote.go
+3
-2
modules/markup/common/linkify.go
+3
-2
modules/markup/common/linkify.go
+1
-1
modules/markup/console/console_test.go
+1
-1
modules/markup/console/console_test.go
+1
-1
modules/markup/csv/csv_test.go
+1
-1
modules/markup/csv/csv_test.go
+1
-1
modules/markup/html.go
+1
-1
modules/markup/html.go
···
363
363
// Add user-content- to IDs and "#" links if they don't already have them
364
364
for idx, attr := range node.Attr {
365
365
val := strings.TrimPrefix(attr.Val, "#")
366
-
notHasPrefix := !(strings.HasPrefix(val, "user-content-") || blackfridayExtRegex.MatchString(val))
366
+
notHasPrefix := !strings.HasPrefix(val, "user-content-") && !blackfridayExtRegex.MatchString(val)
367
367
368
368
if attr.Key == "id" && notHasPrefix {
369
369
node.Attr[idx].Val = "user-content-" + attr.Val
+2
-2
modules/markup/markdown/goldmark.go
+2
-2
modules/markup/markdown/goldmark.go
···
131
131
if entering {
132
132
_, err = w.WriteString("<div")
133
133
if err == nil {
134
-
_, err = w.WriteString(fmt.Sprintf(` lang=%q`, val))
134
+
_, err = fmt.Fprintf(w, ` lang=%q`, val)
135
135
}
136
136
if err == nil {
137
137
_, err = w.WriteRune('>')
···
203
203
return ast.WalkContinue, nil
204
204
}
205
205
206
-
_, err := w.WriteString(fmt.Sprintf(`<i class="icon %s"></i>`, name))
206
+
_, err := fmt.Fprintf(w, `<i class="icon %s"></i>`, name)
207
207
if err != nil {
208
208
return ast.WalkStop, err
209
209
}
+4
-4
modules/markup/markdown/math/inline_parser.go
+4
-4
modules/markup/markdown/math/inline_parser.go
···
99
99
suceedingCharacter := line[pos]
100
100
// check valid ending character
101
101
if !isPunctuation(suceedingCharacter) &&
102
-
!(suceedingCharacter == ' ') &&
103
-
!(suceedingCharacter == '\n') &&
102
+
(suceedingCharacter != ' ') &&
103
+
(suceedingCharacter != '\n') &&
104
104
!isBracket(suceedingCharacter) {
105
105
return nil
106
106
}
···
139
139
140
140
// trim first space and last space
141
141
first := node.FirstChild().(*ast.Text)
142
-
if !(!first.Segment.IsEmpty() && block.Source()[first.Segment.Start] == ' ') {
142
+
if first.Segment.IsEmpty() || block.Source()[first.Segment.Start] != ' ' {
143
143
return
144
144
}
145
145
146
146
last := node.LastChild().(*ast.Text)
147
-
if !(!last.Segment.IsEmpty() && block.Source()[last.Segment.Stop-1] == ' ') {
147
+
if last.Segment.IsEmpty() || block.Source()[last.Segment.Stop-1] != ' ' {
148
148
return
149
149
}
150
150
+2
-2
modules/markup/markdown/meta_test.go
+2
-2
modules/markup/markdown/meta_test.go
···
54
54
var meta IssueTemplate
55
55
body, err := ExtractMetadata(fmt.Sprintf("%s\n%s\n%s", sepTest, frontTest, sepTest), &meta)
56
56
require.NoError(t, err)
57
-
assert.Equal(t, "", body)
57
+
assert.Empty(t, body)
58
58
assert.Equal(t, metaTest, meta)
59
59
assert.True(t, meta.Valid())
60
60
})
···
86
86
var meta IssueTemplate
87
87
body, err := ExtractMetadataBytes([]byte(fmt.Sprintf("%s\n%s\n%s", sepTest, frontTest, sepTest)), &meta)
88
88
require.NoError(t, err)
89
-
assert.Equal(t, "", string(body))
89
+
assert.Empty(t, string(body))
90
90
assert.Equal(t, metaTest, meta)
91
91
assert.True(t, meta.Valid())
92
92
})
+1
-1
modules/markup/markdown/transform_codespan.go
+1
-1
modules/markup/markdown/transform_codespan.go
···
40
40
r.Writer.RawWrite(w, value)
41
41
}
42
42
case *ColorPreview:
43
-
_, _ = w.WriteString(fmt.Sprintf(`<span class="color-preview" style="background-color: %v"></span>`, string(v.Color)))
43
+
_, _ = fmt.Fprintf(w, `<span class="color-preview" style="background-color: %v"></span>`, string(v.Color))
44
44
}
45
45
}
46
46
return ast.WalkSkipChildren, nil
+4
-3
modules/markup/mdstripper/mdstripper.go
+4
-3
modules/markup/mdstripper/mdstripper.go
···
107
107
}
108
108
109
109
var sep string
110
-
if parts[3] == "issues" {
110
+
switch parts[3] {
111
+
case "issues":
111
112
sep = "#"
112
-
} else if parts[3] == "pulls" {
113
+
case "pulls":
113
114
sep = "!"
114
-
} else {
115
+
default:
115
116
// Process out of band
116
117
r.links = append(r.links, linkStr)
117
118
return
+2
-2
modules/markup/mdstripper/mdstripper_test.go
+2
-2
modules/markup/mdstripper/mdstripper_test.go
+6
-6
modules/optional/serialization_test.go
+6
-6
modules/optional/serialization_test.go
···
52
52
t.Run(tc.name, func(t *testing.T) {
53
53
b, err := json.Marshal(tc.obj)
54
54
require.NoError(t, err)
55
-
assert.EqualValues(t, tc.want, string(b), "gitea json module returned unexpected")
55
+
assert.Equal(t, tc.want, string(b), "gitea json module returned unexpected")
56
56
57
57
b, err = std_json.Marshal(tc.obj)
58
58
require.NoError(t, err)
59
-
assert.EqualValues(t, tc.want, string(b), "std json module returned unexpected")
59
+
assert.Equal(t, tc.want, string(b), "std json module returned unexpected")
60
60
})
61
61
}
62
62
}
···
90
90
var obj1 testSerializationStruct
91
91
err := json.Unmarshal([]byte(tc.data), &obj1)
92
92
require.NoError(t, err)
93
-
assert.EqualValues(t, tc.want, obj1, "gitea json module returned unexpected")
93
+
assert.Equal(t, tc.want, obj1, "gitea json module returned unexpected")
94
94
95
95
var obj2 testSerializationStruct
96
96
err = std_json.Unmarshal([]byte(tc.data), &obj2)
97
97
require.NoError(t, err)
98
-
assert.EqualValues(t, tc.want, obj2, "std json module returned unexpected")
98
+
assert.Equal(t, tc.want, obj2, "std json module returned unexpected")
99
99
})
100
100
}
101
101
}
···
136
136
t.Run(tc.name, func(t *testing.T) {
137
137
b, err := yaml.Marshal(tc.obj)
138
138
require.NoError(t, err)
139
-
assert.EqualValues(t, tc.want, string(b), "yaml module returned unexpected")
139
+
assert.Equal(t, tc.want, string(b), "yaml module returned unexpected")
140
140
})
141
141
}
142
142
}
···
185
185
var obj testSerializationStruct
186
186
err := yaml.Unmarshal([]byte(tc.data), &obj)
187
187
require.NoError(t, err)
188
-
assert.EqualValues(t, tc.want, obj, "yaml module returned unexpected")
188
+
assert.Equal(t, tc.want, obj, "yaml module returned unexpected")
189
189
})
190
190
}
191
191
}
+2
-2
modules/packages/cargo/parser_test.go
+2
-2
modules/packages/cargo/parser_test.go
···
98
98
assert.Equal(t, []string{author}, cp.Metadata.Authors)
99
99
assert.Len(t, cp.Metadata.Dependencies, 2)
100
100
assert.Equal(t, "dep", cp.Metadata.Dependencies[0].Name)
101
-
assert.EqualValues(t, "v4l2-sys-mit", cp.Metadata.Dependencies[1].Name)
102
-
assert.EqualValues(t, "v4l2-sys", *cp.Metadata.Dependencies[1].Package)
101
+
assert.Equal(t, "v4l2-sys-mit", cp.Metadata.Dependencies[1].Name)
102
+
assert.Equal(t, "v4l2-sys", *cp.Metadata.Dependencies[1].Package)
103
103
assert.Equal(t, homepage, cp.Metadata.ProjectURL)
104
104
assert.Equal(t, license, cp.Metadata.License)
105
105
content, _ := io.ReadAll(cp.Content)
+24
-24
modules/process/manager_stacktraces_test.go
+24
-24
modules/process/manager_stacktraces_test.go
···
23
23
t.Run("No flat with no system process", func(t *testing.T) {
24
24
processes, processCount, _, err := GetManager().ProcessStacktraces(false, true)
25
25
require.NoError(t, err)
26
-
assert.EqualValues(t, 4, processCount)
26
+
assert.Equal(t, 4, processCount)
27
27
assert.Len(t, processes, 2)
28
28
29
-
assert.EqualValues(t, "Children normal process", processes[0].Description)
30
-
assert.EqualValues(t, NormalProcessType, processes[0].Type)
29
+
assert.Equal(t, "Children normal process", processes[0].Description)
30
+
assert.Equal(t, NormalProcessType, processes[0].Type)
31
31
assert.Empty(t, processes[0].ParentPID)
32
32
assert.Len(t, processes[0].Children, 1)
33
33
34
-
assert.EqualValues(t, "Children process", processes[0].Children[0].Description)
35
-
assert.EqualValues(t, processes[0].PID, processes[0].Children[0].ParentPID)
34
+
assert.Equal(t, "Children process", processes[0].Children[0].Description)
35
+
assert.Equal(t, processes[0].PID, processes[0].Children[0].ParentPID)
36
36
37
-
assert.EqualValues(t, "Normal process", processes[1].Description)
38
-
assert.EqualValues(t, NormalProcessType, processes[1].Type)
37
+
assert.Equal(t, "Normal process", processes[1].Description)
38
+
assert.Equal(t, NormalProcessType, processes[1].Type)
39
39
assert.Empty(t, processes[1].ParentPID)
40
40
assert.Empty(t, processes[1].Children)
41
41
})
···
43
43
t.Run("Flat with no system process", func(t *testing.T) {
44
44
processes, processCount, _, err := GetManager().ProcessStacktraces(true, true)
45
45
require.NoError(t, err)
46
-
assert.EqualValues(t, 4, processCount)
46
+
assert.Equal(t, 4, processCount)
47
47
assert.Len(t, processes, 3)
48
48
49
-
assert.EqualValues(t, "Children process", processes[0].Description)
50
-
assert.EqualValues(t, NormalProcessType, processes[0].Type)
51
-
assert.EqualValues(t, processes[1].PID, processes[0].ParentPID)
49
+
assert.Equal(t, "Children process", processes[0].Description)
50
+
assert.Equal(t, NormalProcessType, processes[0].Type)
51
+
assert.Equal(t, processes[1].PID, processes[0].ParentPID)
52
52
assert.Empty(t, processes[0].Children)
53
53
54
-
assert.EqualValues(t, "Children normal process", processes[1].Description)
55
-
assert.EqualValues(t, NormalProcessType, processes[1].Type)
54
+
assert.Equal(t, "Children normal process", processes[1].Description)
55
+
assert.Equal(t, NormalProcessType, processes[1].Type)
56
56
assert.Empty(t, processes[1].ParentPID)
57
57
assert.Empty(t, processes[1].Children)
58
58
59
-
assert.EqualValues(t, "Normal process", processes[2].Description)
60
-
assert.EqualValues(t, NormalProcessType, processes[2].Type)
59
+
assert.Equal(t, "Normal process", processes[2].Description)
60
+
assert.Equal(t, NormalProcessType, processes[2].Type)
61
61
assert.Empty(t, processes[2].ParentPID)
62
62
assert.Empty(t, processes[2].Children)
63
63
})
···
65
65
t.Run("System process", func(t *testing.T) {
66
66
processes, processCount, _, err := GetManager().ProcessStacktraces(false, false)
67
67
require.NoError(t, err)
68
-
assert.EqualValues(t, 4, processCount)
68
+
assert.Equal(t, 4, processCount)
69
69
assert.Len(t, processes, 4)
70
70
71
-
assert.EqualValues(t, "System process", processes[0].Description)
72
-
assert.EqualValues(t, SystemProcessType, processes[0].Type)
71
+
assert.Equal(t, "System process", processes[0].Description)
72
+
assert.Equal(t, SystemProcessType, processes[0].Type)
73
73
assert.Empty(t, processes[0].ParentPID)
74
74
assert.Empty(t, processes[0].Children)
75
75
76
-
assert.EqualValues(t, "Children normal process", processes[1].Description)
77
-
assert.EqualValues(t, NormalProcessType, processes[1].Type)
76
+
assert.Equal(t, "Children normal process", processes[1].Description)
77
+
assert.Equal(t, NormalProcessType, processes[1].Type)
78
78
assert.Empty(t, processes[1].ParentPID)
79
79
assert.Len(t, processes[1].Children, 1)
80
80
81
-
assert.EqualValues(t, "Normal process", processes[2].Description)
82
-
assert.EqualValues(t, NormalProcessType, processes[2].Type)
81
+
assert.Equal(t, "Normal process", processes[2].Description)
82
+
assert.Equal(t, NormalProcessType, processes[2].Type)
83
83
assert.Empty(t, processes[2].ParentPID)
84
84
assert.Empty(t, processes[2].Children)
85
85
86
86
// This is the "main" pid, testing code always runs in a goroutine.
87
-
assert.EqualValues(t, "(unassociated)", processes[3].Description)
88
-
assert.EqualValues(t, NoneProcessType, processes[3].Type)
87
+
assert.Equal(t, "(unassociated)", processes[3].Description)
88
+
assert.Equal(t, NoneProcessType, processes[3].Type)
89
89
assert.Empty(t, processes[3].ParentPID)
90
90
assert.Empty(t, processes[3].Children)
91
91
})
+10
-10
modules/queue/base_test.go
+10
-10
modules/queue/base_test.go
···
22
22
_ = q.RemoveAll(ctx)
23
23
cnt, err := q.Len(ctx)
24
24
require.NoError(t, err)
25
-
assert.EqualValues(t, 0, cnt)
25
+
assert.Equal(t, 0, cnt)
26
26
27
27
// push the first item
28
28
err = q.PushItem(ctx, []byte("foo"))
···
30
30
31
31
cnt, err = q.Len(ctx)
32
32
require.NoError(t, err)
33
-
assert.EqualValues(t, 1, cnt)
33
+
assert.Equal(t, 1, cnt)
34
34
35
35
// push a duplicate item
36
36
err = q.PushItem(ctx, []byte("foo"))
···
46
46
has, err := q.HasItem(ctx, []byte("foo"))
47
47
require.NoError(t, err)
48
48
if !isUnique {
49
-
assert.EqualValues(t, 2, cnt)
49
+
assert.Equal(t, 2, cnt)
50
50
assert.False(t, has) // non-unique queues don't check for duplicates
51
51
} else {
52
-
assert.EqualValues(t, 1, cnt)
52
+
assert.Equal(t, 1, cnt)
53
53
assert.True(t, has)
54
54
}
55
55
···
60
60
// pop the first item (and the duplicate if non-unique)
61
61
it, err := q.PopItem(ctx)
62
62
require.NoError(t, err)
63
-
assert.EqualValues(t, "foo", string(it))
63
+
assert.Equal(t, "foo", string(it))
64
64
65
65
if !isUnique {
66
66
it, err = q.PopItem(ctx)
67
67
require.NoError(t, err)
68
-
assert.EqualValues(t, "foo", string(it))
68
+
assert.Equal(t, "foo", string(it))
69
69
}
70
70
71
71
// pop another item
72
72
it, err = q.PopItem(ctx)
73
73
require.NoError(t, err)
74
-
assert.EqualValues(t, "bar", string(it))
74
+
assert.Equal(t, "bar", string(it))
75
75
76
76
// pop an empty queue (timeout, cancel)
77
77
ctxTimed, cancel := context.WithTimeout(ctx, 10*time.Millisecond)
···
108
108
// remove all
109
109
cnt, err = q.Len(ctx)
110
110
require.NoError(t, err)
111
-
assert.EqualValues(t, cfg.Length, cnt)
111
+
assert.Equal(t, cfg.Length, cnt)
112
112
113
113
_ = q.RemoveAll(ctx)
114
114
115
115
cnt, err = q.Len(ctx)
116
116
require.NoError(t, err)
117
-
assert.EqualValues(t, 0, cnt)
117
+
assert.Equal(t, 0, cnt)
118
118
})
119
119
}
120
120
···
127
127
128
128
cnt, err := q.Len(ctx)
129
129
require.NoError(t, err)
130
-
assert.EqualValues(t, 0, cnt)
130
+
assert.Equal(t, 0, cnt)
131
131
132
132
has, err := q.HasItem(ctx, []byte("foo"))
133
133
require.NoError(t, err)
+2
-2
modules/queue/manager_test.go
+2
-2
modules/queue/manager_test.go
···
48
48
assert.Equal(t, filepath.Join(setting.AppDataPath, "queues/common"), q.baseConfig.DataFullDir)
49
49
assert.Equal(t, 100000, q.baseConfig.Length)
50
50
assert.Equal(t, 20, q.batchLength)
51
-
assert.Equal(t, "", q.baseConfig.ConnStr)
51
+
assert.Empty(t, q.baseConfig.ConnStr)
52
52
assert.Equal(t, "default_queue", q.baseConfig.QueueFullName)
53
53
assert.Equal(t, "default_queue_unique", q.baseConfig.SetFullName)
54
54
assert.NotZero(t, q.GetWorkerMaxNumber())
···
102
102
assert.Equal(t, filepath.Join(setting.AppDataPath, "queues/dir2"), q2.baseConfig.DataFullDir)
103
103
assert.Equal(t, 102, q2.baseConfig.Length)
104
104
assert.Equal(t, 22, q2.batchLength)
105
-
assert.Equal(t, "", q2.baseConfig.ConnStr)
105
+
assert.Empty(t, q2.baseConfig.ConnStr)
106
106
assert.Equal(t, "sub_q2", q2.baseConfig.QueueFullName)
107
107
assert.Equal(t, "sub_q2_u2", q2.baseConfig.SetFullName)
108
108
assert.Equal(t, 123, q2.GetWorkerMaxNumber())
+16
-16
modules/queue/workerqueue_test.go
+16
-16
modules/queue/workerqueue_test.go
···
64
64
ok := true
65
65
for i := 0; i < queueSetting.Length; i++ {
66
66
if i%2 == 0 {
67
-
ok = ok && assert.EqualValues(t, 2, m[i], "test %s: item %d", t.Name(), i)
67
+
ok = ok && assert.Equal(t, 2, m[i], "test %s: item %d", t.Name(), i)
68
68
} else {
69
-
ok = ok && assert.EqualValues(t, 1, m[i], "test %s: item %d", t.Name(), i)
69
+
ok = ok && assert.Equal(t, 1, m[i], "test %s: item %d", t.Name(), i)
70
70
}
71
71
}
72
72
if !ok {
···
174
174
175
175
assert.NotEmpty(t, tasksQ1)
176
176
assert.NotEmpty(t, tasksQ2)
177
-
assert.EqualValues(t, testCount, len(tasksQ1)+len(tasksQ2))
177
+
assert.Equal(t, testCount, len(tasksQ1)+len(tasksQ2))
178
178
}
179
179
180
180
func TestWorkerPoolQueueActiveWorkers(t *testing.T) {
···
192
192
}
193
193
194
194
time.Sleep(50 * time.Millisecond)
195
-
assert.EqualValues(t, 1, q.GetWorkerNumber())
196
-
assert.EqualValues(t, 1, q.GetWorkerActiveNumber())
195
+
assert.Equal(t, 1, q.GetWorkerNumber())
196
+
assert.Equal(t, 1, q.GetWorkerActiveNumber())
197
197
time.Sleep(500 * time.Millisecond)
198
-
assert.EqualValues(t, 1, q.GetWorkerNumber())
199
-
assert.EqualValues(t, 0, q.GetWorkerActiveNumber())
198
+
assert.Equal(t, 1, q.GetWorkerNumber())
199
+
assert.Equal(t, 0, q.GetWorkerActiveNumber())
200
200
time.Sleep(workerIdleDuration)
201
-
assert.EqualValues(t, 1, q.GetWorkerNumber()) // there is at least one worker after the queue begins working
201
+
assert.Equal(t, 1, q.GetWorkerNumber()) // there is at least one worker after the queue begins working
202
202
stop()
203
203
204
204
q, _ = newWorkerPoolQueueForTest("test-workpoolqueue", setting.QueueSettings{Type: "channel", BatchLength: 1, MaxWorkers: 3, Length: 100}, handler, false)
···
208
208
}
209
209
210
210
time.Sleep(50 * time.Millisecond)
211
-
assert.EqualValues(t, 3, q.GetWorkerNumber())
212
-
assert.EqualValues(t, 3, q.GetWorkerActiveNumber())
211
+
assert.Equal(t, 3, q.GetWorkerNumber())
212
+
assert.Equal(t, 3, q.GetWorkerActiveNumber())
213
213
time.Sleep(500 * time.Millisecond)
214
-
assert.EqualValues(t, 3, q.GetWorkerNumber())
215
-
assert.EqualValues(t, 0, q.GetWorkerActiveNumber())
214
+
assert.Equal(t, 3, q.GetWorkerNumber())
215
+
assert.Equal(t, 0, q.GetWorkerActiveNumber())
216
216
time.Sleep(workerIdleDuration)
217
-
assert.EqualValues(t, 1, q.GetWorkerNumber()) // there is at least one worker after the queue begins working
217
+
assert.Equal(t, 1, q.GetWorkerNumber()) // there is at least one worker after the queue begins working
218
218
stop()
219
219
}
220
220
···
241
241
}
242
242
<-handlerCalled
243
243
time.Sleep(200 * time.Millisecond) // wait for a while to make sure all workers are active
244
-
assert.EqualValues(t, 4, q.GetWorkerActiveNumber())
244
+
assert.Equal(t, 4, q.GetWorkerActiveNumber())
245
245
stop() // stop triggers shutdown
246
-
assert.EqualValues(t, 0, q.GetWorkerActiveNumber())
246
+
assert.Equal(t, 0, q.GetWorkerActiveNumber())
247
247
248
248
// no item was ever handled, so we still get all of them again
249
249
q, _ = newWorkerPoolQueueForTest("test-workpoolqueue", qs, handler, false)
250
-
assert.EqualValues(t, 20, q.GetQueueItemNumber())
250
+
assert.Equal(t, 20, q.GetQueueItemNumber())
251
251
}
252
252
253
253
func TestWorkerPoolQueueWorkerIdleReset(t *testing.T) {
+4
-3
modules/references/references.go
+4
-3
modules/references/references.go
···
464
464
continue
465
465
}
466
466
var sep string
467
-
if parts[3] == "issues" {
467
+
switch parts[3] {
468
+
case "issues":
468
469
sep = "#"
469
-
} else if parts[3] == "pulls" {
470
+
case "pulls":
470
471
sep = "!"
471
-
} else {
472
+
default:
472
473
continue
473
474
}
474
475
// Note: closing/reopening keywords not supported with URLs
+5
-5
modules/references/references_test.go
+5
-5
modules/references/references_test.go
···
46
46
contentBytes := []byte(test)
47
47
convertFullHTMLReferencesToShortRefs(re, &contentBytes)
48
48
result := string(contentBytes)
49
-
assert.EqualValues(t, expect, result)
49
+
assert.Equal(t, expect, result)
50
50
}
51
51
52
52
func TestFindAllIssueReferences(t *testing.T) {
···
284
284
}
285
285
expref := rawToIssueReferenceList(expraw)
286
286
refs := FindAllIssueReferencesMarkdown(fixture.input)
287
-
assert.EqualValues(t, expref, refs, "[%s] Failed to parse: {%s}", context, fixture.input)
287
+
assert.Equal(t, expref, refs, "[%s] Failed to parse: {%s}", context, fixture.input)
288
288
rawrefs := findAllIssueReferencesMarkdown(fixture.input)
289
-
assert.EqualValues(t, expraw, rawrefs, "[%s] Failed to parse: {%s}", context, fixture.input)
289
+
assert.Equal(t, expraw, rawrefs, "[%s] Failed to parse: {%s}", context, fixture.input)
290
290
}
291
291
292
292
// Restore for other tests that may rely on the original value
···
295
295
296
296
func TestFindAllMentions(t *testing.T) {
297
297
res := FindAllMentionsBytes([]byte("@tasha, @mike; @lucy: @john"))
298
-
assert.EqualValues(t, []RefSpan{
298
+
assert.Equal(t, []RefSpan{
299
299
{Start: 0, End: 6},
300
300
{Start: 8, End: 13},
301
301
{Start: 15, End: 20},
···
558
558
res := pat.FindAllStringSubmatch(test.match, -1)
559
559
assert.Len(t, res, 1)
560
560
assert.Len(t, res[0], 2)
561
-
assert.EqualValues(t, test.expected, res[0][1])
561
+
assert.Equal(t, test.expected, res[0][1])
562
562
}
563
563
}
564
564
}
+2
-2
modules/regexplru/regexplru_test.go
+2
-2
modules/regexplru/regexplru_test.go
···
19
19
require.NoError(t, err)
20
20
assert.True(t, r.MatchString("a"))
21
21
22
-
assert.EqualValues(t, 1, lruCache.Len())
22
+
assert.Equal(t, 1, lruCache.Len())
23
23
24
24
_, err = GetCompiled("(")
25
25
require.Error(t, err)
26
-
assert.EqualValues(t, 2, lruCache.Len())
26
+
assert.Equal(t, 2, lruCache.Len())
27
27
}
+1
-1
modules/repository/branch_test.go
+1
-1
modules/repository/branch_test.go
+12
-12
modules/repository/commits_test.go
+12
-12
modules/repository/commits_test.go
···
63
63
assert.Equal(t, "user2", payloadCommits[0].Committer.UserName)
64
64
assert.Equal(t, "User2", payloadCommits[0].Author.Name)
65
65
assert.Equal(t, "user2", payloadCommits[0].Author.UserName)
66
-
assert.EqualValues(t, []string{}, payloadCommits[0].Added)
67
-
assert.EqualValues(t, []string{}, payloadCommits[0].Removed)
68
-
assert.EqualValues(t, []string{"readme.md"}, payloadCommits[0].Modified)
66
+
assert.Equal(t, []string{}, payloadCommits[0].Added)
67
+
assert.Equal(t, []string{}, payloadCommits[0].Removed)
68
+
assert.Equal(t, []string{"readme.md"}, payloadCommits[0].Modified)
69
69
70
70
assert.Equal(t, "27566bd", payloadCommits[1].ID)
71
71
assert.Equal(t, "good signed commit (with not yet validated email)", payloadCommits[1].Message)
···
74
74
assert.Equal(t, "user2", payloadCommits[1].Committer.UserName)
75
75
assert.Equal(t, "User2", payloadCommits[1].Author.Name)
76
76
assert.Equal(t, "user2", payloadCommits[1].Author.UserName)
77
-
assert.EqualValues(t, []string{}, payloadCommits[1].Added)
78
-
assert.EqualValues(t, []string{}, payloadCommits[1].Removed)
79
-
assert.EqualValues(t, []string{"readme.md"}, payloadCommits[1].Modified)
77
+
assert.Equal(t, []string{}, payloadCommits[1].Added)
78
+
assert.Equal(t, []string{}, payloadCommits[1].Removed)
79
+
assert.Equal(t, []string{"readme.md"}, payloadCommits[1].Modified)
80
80
81
81
assert.Equal(t, "5099b81", payloadCommits[2].ID)
82
82
assert.Equal(t, "good signed commit", payloadCommits[2].Message)
···
85
85
assert.Equal(t, "user2", payloadCommits[2].Committer.UserName)
86
86
assert.Equal(t, "User2", payloadCommits[2].Author.Name)
87
87
assert.Equal(t, "user2", payloadCommits[2].Author.UserName)
88
-
assert.EqualValues(t, []string{"readme.md"}, payloadCommits[2].Added)
89
-
assert.EqualValues(t, []string{}, payloadCommits[2].Removed)
90
-
assert.EqualValues(t, []string{}, payloadCommits[2].Modified)
88
+
assert.Equal(t, []string{"readme.md"}, payloadCommits[2].Added)
89
+
assert.Equal(t, []string{}, payloadCommits[2].Removed)
90
+
assert.Equal(t, []string{}, payloadCommits[2].Modified)
91
91
92
92
assert.Equal(t, "69554a6", headCommit.ID)
93
93
assert.Equal(t, "not signed commit", headCommit.Message)
···
96
96
assert.Equal(t, "user2", headCommit.Committer.UserName)
97
97
assert.Equal(t, "User2", headCommit.Author.Name)
98
98
assert.Equal(t, "user2", headCommit.Author.UserName)
99
-
assert.EqualValues(t, []string{}, headCommit.Added)
100
-
assert.EqualValues(t, []string{}, headCommit.Removed)
101
-
assert.EqualValues(t, []string{"readme.md"}, headCommit.Modified)
99
+
assert.Equal(t, []string{}, headCommit.Added)
100
+
assert.Equal(t, []string{}, headCommit.Removed)
101
+
assert.Equal(t, []string{"readme.md"}, headCommit.Modified)
102
102
}
103
103
104
104
func TestPushCommits_AvatarLink(t *testing.T) {
+4
-3
modules/repository/create.go
+4
-3
modules/repository/create.go
···
73
73
}
74
74
units := make([]repo_model.RepoUnit, 0, len(defaultUnits))
75
75
for _, tp := range defaultUnits {
76
-
if tp == unit.TypeIssues {
76
+
switch tp {
77
+
case unit.TypeIssues:
77
78
units = append(units, repo_model.RepoUnit{
78
79
RepoID: repo.ID,
79
80
Type: tp,
···
83
84
EnableDependencies: setting.Service.DefaultEnableDependencies,
84
85
},
85
86
})
86
-
} else if tp == unit.TypePullRequests {
87
+
case unit.TypePullRequests:
87
88
units = append(units, repo_model.RepoUnit{
88
89
RepoID: repo.ID,
89
90
Type: tp,
···
94
95
AllowRebaseUpdate: true,
95
96
},
96
97
})
97
-
} else {
98
+
default:
98
99
units = append(units, repo_model.RepoUnit{
99
100
RepoID: repo.ID,
100
101
Type: tp,
+1
-1
modules/repository/create_test.go
+1
-1
modules/repository/create_test.go
+3
-3
modules/repository/init_test.go
+3
-3
modules/repository/init_test.go
···
14
14
all: []string{"a", "a.yaml", "a.yml"},
15
15
custom: nil,
16
16
})
17
-
assert.EqualValues(t, []string{"a.yaml"}, files, "yaml file should win")
17
+
assert.Equal(t, []string{"a.yaml"}, files, "yaml file should win")
18
18
19
19
files = mergeCustomLabelFiles(optionFileList{
20
20
all: []string{"a", "a.yaml"},
21
21
custom: []string{"a"},
22
22
})
23
-
assert.EqualValues(t, []string{"a"}, files, "custom file should win")
23
+
assert.Equal(t, []string{"a"}, files, "custom file should win")
24
24
25
25
files = mergeCustomLabelFiles(optionFileList{
26
26
all: []string{"a", "a.yml", "a.yaml"},
27
27
custom: []string{"a", "a.yml"},
28
28
})
29
-
assert.EqualValues(t, []string{"a.yml"}, files, "custom yml file should win if no yaml")
29
+
assert.Equal(t, []string{"a.yml"}, files, "custom yml file should win if no yaml")
30
30
}
+3
-2
modules/repository/license.go
+3
-2
modules/repository/license.go
···
99
99
100
100
// Some special placeholders for specific licenses.
101
101
// It's unsafe to apply them to all licenses.
102
-
if name == "0BSD" {
102
+
switch name {
103
+
case "0BSD":
103
104
return &licensePlaceholder{
104
105
Owner: []string{"AUTHOR"},
105
106
Email: []string{"EMAIL"},
···
108
109
}
109
110
110
111
// Other special placeholders can be added here.
111
-
} else if name == "BSD-4-Clause" {
112
+
case "BSD-4-Clause":
112
113
ret.Owner = append(ret.Owner, "COPYRIGHT HOLDER")
113
114
ret.Owner = append(ret.Owner, "the organization")
114
115
}
+2
-2
modules/repository/repo_test.go
+2
-2
modules/repository/repo_test.go
···
63
63
64
64
inserts, deletes, updates := calcSync(gitTags, dbReleases)
65
65
if assert.Len(t, inserts, 1, "inserts") {
66
-
assert.EqualValues(t, *gitTags[2], *inserts[0], "inserts equal")
66
+
assert.Equal(t, *gitTags[2], *inserts[0], "inserts equal")
67
67
}
68
68
69
69
if assert.Len(t, deletes, 1, "deletes") {
···
71
71
}
72
72
73
73
if assert.Len(t, updates, 1, "updates") {
74
-
assert.EqualValues(t, *gitTags[1], *updates[0], "updates equal")
74
+
assert.Equal(t, *gitTags[1], *updates[0], "updates equal")
75
75
}
76
76
}
+13
-13
modules/setting/actions_test.go
+13
-13
modules/setting/actions_test.go
···
21
21
require.NoError(t, loadActionsFrom(cfg))
22
22
23
23
assert.EqualValues(t, "minio", Actions.LogStorage.Type)
24
-
assert.EqualValues(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
24
+
assert.Equal(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
25
25
assert.EqualValues(t, "minio", Actions.ArtifactStorage.Type)
26
-
assert.EqualValues(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
26
+
assert.Equal(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
27
27
28
28
iniStr = `
29
29
[storage.actions_log]
···
34
34
require.NoError(t, loadActionsFrom(cfg))
35
35
36
36
assert.EqualValues(t, "minio", Actions.LogStorage.Type)
37
-
assert.EqualValues(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
37
+
assert.Equal(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
38
38
assert.EqualValues(t, "local", Actions.ArtifactStorage.Type)
39
-
assert.EqualValues(t, "actions_artifacts", filepath.Base(Actions.ArtifactStorage.Path))
39
+
assert.Equal(t, "actions_artifacts", filepath.Base(Actions.ArtifactStorage.Path))
40
40
41
41
iniStr = `
42
42
[storage.actions_log]
···
50
50
require.NoError(t, loadActionsFrom(cfg))
51
51
52
52
assert.EqualValues(t, "minio", Actions.LogStorage.Type)
53
-
assert.EqualValues(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
53
+
assert.Equal(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
54
54
assert.EqualValues(t, "local", Actions.ArtifactStorage.Type)
55
-
assert.EqualValues(t, "actions_artifacts", filepath.Base(Actions.ArtifactStorage.Path))
55
+
assert.Equal(t, "actions_artifacts", filepath.Base(Actions.ArtifactStorage.Path))
56
56
57
57
iniStr = `
58
58
[storage.actions_artifacts]
···
66
66
require.NoError(t, loadActionsFrom(cfg))
67
67
68
68
assert.EqualValues(t, "local", Actions.LogStorage.Type)
69
-
assert.EqualValues(t, "actions_log", filepath.Base(Actions.LogStorage.Path))
69
+
assert.Equal(t, "actions_log", filepath.Base(Actions.LogStorage.Path))
70
70
assert.EqualValues(t, "minio", Actions.ArtifactStorage.Type)
71
-
assert.EqualValues(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
71
+
assert.Equal(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
72
72
73
73
iniStr = `
74
74
[storage.actions_artifacts]
···
82
82
require.NoError(t, loadActionsFrom(cfg))
83
83
84
84
assert.EqualValues(t, "local", Actions.LogStorage.Type)
85
-
assert.EqualValues(t, "actions_log", filepath.Base(Actions.LogStorage.Path))
85
+
assert.Equal(t, "actions_log", filepath.Base(Actions.LogStorage.Path))
86
86
assert.EqualValues(t, "minio", Actions.ArtifactStorage.Type)
87
-
assert.EqualValues(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
87
+
assert.Equal(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
88
88
89
89
iniStr = ``
90
90
cfg, err = NewConfigProviderFromData(iniStr)
···
92
92
require.NoError(t, loadActionsFrom(cfg))
93
93
94
94
assert.EqualValues(t, "local", Actions.LogStorage.Type)
95
-
assert.EqualValues(t, "actions_log", filepath.Base(Actions.LogStorage.Path))
95
+
assert.Equal(t, "actions_log", filepath.Base(Actions.LogStorage.Path))
96
96
assert.EqualValues(t, "local", Actions.ArtifactStorage.Type)
97
-
assert.EqualValues(t, "actions_artifacts", filepath.Base(Actions.ArtifactStorage.Path))
97
+
assert.Equal(t, "actions_artifacts", filepath.Base(Actions.ArtifactStorage.Path))
98
98
}
99
99
100
100
func Test_getDefaultActionsURLForActions(t *testing.T) {
···
151
151
require.NoError(t, err)
152
152
require.NoError(t, loadActionsFrom(cfg))
153
153
154
-
assert.EqualValues(t, tt.wantURL, Actions.DefaultActionsURL.URL())
154
+
assert.Equal(t, tt.wantURL, Actions.DefaultActionsURL.URL())
155
155
})
156
156
}
157
157
}
+3
-3
modules/setting/admin_test.go
+3
-3
modules/setting/admin_test.go
···
26
26
loadAdminFrom(cfg)
27
27
28
28
assert.True(t, Admin.DisableRegularOrgCreation)
29
-
assert.EqualValues(t, "z", Admin.DefaultEmailNotification)
29
+
assert.Equal(t, "z", Admin.DefaultEmailNotification)
30
30
assert.True(t, Admin.SendNotificationEmailOnNewUser)
31
-
assert.EqualValues(t, container.SetOf("a", "b"), Admin.UserDisabledFeatures)
32
-
assert.EqualValues(t, container.SetOf("x", "y"), Admin.ExternalUserDisableFeatures)
31
+
assert.Equal(t, container.SetOf("a", "b"), Admin.UserDisabledFeatures)
32
+
assert.Equal(t, container.SetOf("x", "y"), Admin.ExternalUserDisableFeatures)
33
33
}
+11
-11
modules/setting/attachment_test.go
+11
-11
modules/setting/attachment_test.go
···
26
26
require.NoError(t, loadAttachmentFrom(cfg))
27
27
28
28
assert.EqualValues(t, "minio", Attachment.Storage.Type)
29
-
assert.EqualValues(t, "my_minio:9000", Attachment.Storage.MinioConfig.Endpoint)
30
-
assert.EqualValues(t, "gitea-attachment", Attachment.Storage.MinioConfig.Bucket)
31
-
assert.EqualValues(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
29
+
assert.Equal(t, "my_minio:9000", Attachment.Storage.MinioConfig.Endpoint)
30
+
assert.Equal(t, "gitea-attachment", Attachment.Storage.MinioConfig.Bucket)
31
+
assert.Equal(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
32
32
}
33
33
34
34
func Test_getStorageTypeSectionOverridesStorageSection(t *testing.T) {
···
48
48
require.NoError(t, loadAttachmentFrom(cfg))
49
49
50
50
assert.EqualValues(t, "minio", Attachment.Storage.Type)
51
-
assert.EqualValues(t, "gitea-minio", Attachment.Storage.MinioConfig.Bucket)
52
-
assert.EqualValues(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
51
+
assert.Equal(t, "gitea-minio", Attachment.Storage.MinioConfig.Bucket)
52
+
assert.Equal(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
53
53
}
54
54
55
55
func Test_getStorageSpecificOverridesStorage(t *testing.T) {
···
70
70
require.NoError(t, loadAttachmentFrom(cfg))
71
71
72
72
assert.EqualValues(t, "minio", Attachment.Storage.Type)
73
-
assert.EqualValues(t, "gitea-attachment", Attachment.Storage.MinioConfig.Bucket)
74
-
assert.EqualValues(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
73
+
assert.Equal(t, "gitea-attachment", Attachment.Storage.MinioConfig.Bucket)
74
+
assert.Equal(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
75
75
}
76
76
77
77
func Test_getStorageGetDefaults(t *testing.T) {
···
81
81
require.NoError(t, loadAttachmentFrom(cfg))
82
82
83
83
// default storage is local, so bucket is empty
84
-
assert.EqualValues(t, "", Attachment.Storage.MinioConfig.Bucket)
84
+
assert.Empty(t, Attachment.Storage.MinioConfig.Bucket)
85
85
}
86
86
87
87
func Test_getStorageInheritNameSectionType(t *testing.T) {
···
116
116
storage := Attachment.Storage
117
117
118
118
assert.EqualValues(t, "minio", storage.Type)
119
-
assert.EqualValues(t, "gitea", storage.MinioConfig.Bucket)
119
+
assert.Equal(t, "gitea", storage.MinioConfig.Bucket)
120
120
}
121
121
122
122
func Test_AttachmentStorage1(t *testing.T) {
···
129
129
130
130
require.NoError(t, loadAttachmentFrom(cfg))
131
131
assert.EqualValues(t, "minio", Attachment.Storage.Type)
132
-
assert.EqualValues(t, "gitea", Attachment.Storage.MinioConfig.Bucket)
133
-
assert.EqualValues(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
132
+
assert.Equal(t, "gitea", Attachment.Storage.MinioConfig.Bucket)
133
+
assert.Equal(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
134
134
}
+9
-9
modules/setting/config_env_test.go
+9
-9
modules/setting/config_env_test.go
···
30
30
31
31
ok, section, key = decodeEnvSectionKey("SEC")
32
32
assert.False(t, ok)
33
-
assert.Equal(t, "", section)
34
-
assert.Equal(t, "", key)
33
+
assert.Empty(t, section)
34
+
assert.Empty(t, key)
35
35
}
36
36
37
37
func TestDecodeEnvironmentKey(t *testing.T) {
···
40
40
41
41
ok, section, key, file := decodeEnvironmentKey(prefix, suffix, "SEC__KEY")
42
42
assert.False(t, ok)
43
-
assert.Equal(t, "", section)
44
-
assert.Equal(t, "", key)
43
+
assert.Empty(t, section)
44
+
assert.Empty(t, key)
45
45
assert.False(t, file)
46
46
47
47
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA__SEC")
48
48
assert.False(t, ok)
49
-
assert.Equal(t, "", section)
50
-
assert.Equal(t, "", key)
49
+
assert.Empty(t, section)
50
+
assert.Empty(t, key)
51
51
assert.False(t, file)
52
52
53
53
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA____KEY")
54
54
assert.True(t, ok)
55
-
assert.Equal(t, "", section)
55
+
assert.Empty(t, section)
56
56
assert.Equal(t, "KEY", key)
57
57
assert.False(t, file)
58
58
···
72
72
// but it could be fixed in the future by adding a new suffix like "__VALUE" (no such key VALUE is used in Gitea either)
73
73
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA__SEC__FILE")
74
74
assert.False(t, ok)
75
-
assert.Equal(t, "", section)
76
-
assert.Equal(t, "", key)
75
+
assert.Empty(t, section)
76
+
assert.Empty(t, key)
77
77
assert.True(t, file)
78
78
79
79
ok, section, key, file = decodeEnvironmentKey(prefix, suffix, "GITEA__SEC__KEY__FILE")
+4
-4
modules/setting/config_provider_test.go
+4
-4
modules/setting/config_provider_test.go
···
63
63
64
64
// test default behavior
65
65
assert.Equal(t, "123", ConfigSectionKeyString(sec, "key"))
66
-
assert.Equal(t, "", ConfigSectionKeyString(secSub, "key"))
66
+
assert.Empty(t, ConfigSectionKeyString(secSub, "key"))
67
67
assert.Equal(t, "def", ConfigSectionKeyString(secSub, "key", "def"))
68
68
69
69
assert.Equal(t, "123", ConfigInheritedKeyString(secSub, "key"))
70
70
71
71
// Workaround for ini package's BuggyKeyOverwritten behavior
72
-
assert.Equal(t, "", ConfigSectionKeyString(sec, "empty"))
73
-
assert.Equal(t, "", ConfigSectionKeyString(secSub, "empty"))
72
+
assert.Empty(t, ConfigSectionKeyString(sec, "empty"))
73
+
assert.Empty(t, ConfigSectionKeyString(secSub, "empty"))
74
74
assert.Equal(t, "def", ConfigInheritedKey(secSub, "empty").MustString("def"))
75
75
assert.Equal(t, "def", ConfigInheritedKey(secSub, "empty").MustString("xyz"))
76
-
assert.Equal(t, "", ConfigSectionKeyString(sec, "empty"))
76
+
assert.Empty(t, ConfigSectionKeyString(sec, "empty"))
77
77
assert.Equal(t, "def", ConfigSectionKeyString(secSub, "empty"))
78
78
}
79
79
+1
-1
modules/setting/cron_test.go
+1
-1
modules/setting/cron_test.go
+2
-2
modules/setting/forgejo_storage_test.go
+2
-2
modules/setting/forgejo_storage_test.go
···
259
259
cfg, err := NewConfigProviderFromData(iniStr)
260
260
require.NoError(t, err, iniStr)
261
261
require.NoError(t, loadCommonSettingsFrom(cfg), iniStr)
262
-
assert.EqualValues(t, testSectionToPath(storageType, section), testStorageGetPath(*storage), iniStr)
263
-
assert.EqualValues(t, storageType, (*storage).Type, iniStr)
262
+
assert.Equal(t, testSectionToPath(storageType, section), testStorageGetPath(*storage), iniStr)
263
+
assert.Equal(t, storageType, (*storage).Type, iniStr)
264
264
}
+7
-7
modules/setting/git_test.go
+7
-7
modules/setting/git_test.go
···
24
24
`)
25
25
require.NoError(t, err)
26
26
loadGitFrom(cfg)
27
-
assert.EqualValues(t, "1", GitConfig.Options["a.b"])
28
-
assert.EqualValues(t, "histogram", GitConfig.Options["diff.algorithm"])
27
+
assert.Equal(t, "1", GitConfig.Options["a.b"])
28
+
assert.Equal(t, "histogram", GitConfig.Options["diff.algorithm"])
29
29
30
30
cfg, err = NewConfigProviderFromData(`
31
31
[git.config]
···
33
33
`)
34
34
require.NoError(t, err)
35
35
loadGitFrom(cfg)
36
-
assert.EqualValues(t, "other", GitConfig.Options["diff.algorithm"])
36
+
assert.Equal(t, "other", GitConfig.Options["diff.algorithm"])
37
37
}
38
38
39
39
func TestGitReflog(t *testing.T) {
···
49
49
require.NoError(t, err)
50
50
loadGitFrom(cfg)
51
51
52
-
assert.EqualValues(t, "true", GitConfig.GetOption("core.logAllRefUpdates"))
53
-
assert.EqualValues(t, "90", GitConfig.GetOption("gc.reflogExpire"))
52
+
assert.Equal(t, "true", GitConfig.GetOption("core.logAllRefUpdates"))
53
+
assert.Equal(t, "90", GitConfig.GetOption("gc.reflogExpire"))
54
54
55
55
// custom reflog config by legacy options
56
56
cfg, err = NewConfigProviderFromData(`
···
61
61
require.NoError(t, err)
62
62
loadGitFrom(cfg)
63
63
64
-
assert.EqualValues(t, "false", GitConfig.GetOption("core.logAllRefUpdates"))
65
-
assert.EqualValues(t, "123", GitConfig.GetOption("gc.reflogExpire"))
64
+
assert.Equal(t, "false", GitConfig.GetOption("core.logAllRefUpdates"))
65
+
assert.Equal(t, "123", GitConfig.GetOption("gc.reflogExpire"))
66
66
}
+5
-5
modules/setting/incoming_email_test.go
+5
-5
modules/setting/incoming_email_test.go
···
31
31
32
32
loadIncomingEmailFrom(cfg)
33
33
34
-
assert.EqualValues(t, "jane.doe@example.com", IncomingEmail.Username)
35
-
assert.EqualValues(t, "y0u'll n3v3r gUess th1S!!1", IncomingEmail.Password)
34
+
assert.Equal(t, "jane.doe@example.com", IncomingEmail.Username)
35
+
assert.Equal(t, "y0u'll n3v3r gUess th1S!!1", IncomingEmail.Password)
36
36
})
37
37
38
38
t.Run("Port settings", func(t *testing.T) {
···
45
45
46
46
loadIncomingEmailFrom(cfg)
47
47
48
-
assert.EqualValues(t, 143, IncomingEmail.Port)
48
+
assert.Equal(t, 143, IncomingEmail.Port)
49
49
})
50
50
51
51
t.Run("no port, with tls", func(t *testing.T) {
···
56
56
57
57
loadIncomingEmailFrom(cfg)
58
58
59
-
assert.EqualValues(t, 993, IncomingEmail.Port)
59
+
assert.Equal(t, 993, IncomingEmail.Port)
60
60
})
61
61
62
62
t.Run("port overrides tls", func(t *testing.T) {
···
68
68
69
69
loadIncomingEmailFrom(cfg)
70
70
71
-
assert.EqualValues(t, 1993, IncomingEmail.Port)
71
+
assert.Equal(t, 1993, IncomingEmail.Port)
72
72
})
73
73
})
74
74
}
+11
-11
modules/setting/lfs_test.go
+11
-11
modules/setting/lfs_test.go
···
20
20
require.NoError(t, loadLFSFrom(cfg))
21
21
22
22
assert.EqualValues(t, "minio", LFS.Storage.Type)
23
-
assert.EqualValues(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
23
+
assert.Equal(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
24
24
25
25
iniStr = `
26
26
[server]
···
55
55
require.NoError(t, loadLFSFrom(cfg))
56
56
57
57
assert.EqualValues(t, "minio", LFS.Storage.Type)
58
-
assert.EqualValues(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
58
+
assert.Equal(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
59
59
60
60
iniStr = `
61
61
[lfs]
···
69
69
require.NoError(t, loadLFSFrom(cfg))
70
70
71
71
assert.EqualValues(t, "minio", LFS.Storage.Type)
72
-
assert.EqualValues(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
72
+
assert.Equal(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
73
73
74
74
iniStr = `
75
75
[lfs]
···
84
84
require.NoError(t, loadLFSFrom(cfg))
85
85
86
86
assert.EqualValues(t, "minio", LFS.Storage.Type)
87
-
assert.EqualValues(t, "my_lfs/", LFS.Storage.MinioConfig.BasePath)
87
+
assert.Equal(t, "my_lfs/", LFS.Storage.MinioConfig.BasePath)
88
88
}
89
89
90
90
func Test_LFSStorage1(t *testing.T) {
···
97
97
98
98
require.NoError(t, loadLFSFrom(cfg))
99
99
assert.EqualValues(t, "minio", LFS.Storage.Type)
100
-
assert.EqualValues(t, "gitea", LFS.Storage.MinioConfig.Bucket)
101
-
assert.EqualValues(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
100
+
assert.Equal(t, "gitea", LFS.Storage.MinioConfig.Bucket)
101
+
assert.Equal(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
102
102
}
103
103
104
104
func Test_LFSClientServerConfigs(t *testing.T) {
···
113
113
assert.NoError(t, err)
114
114
115
115
assert.NoError(t, loadLFSFrom(cfg))
116
-
assert.EqualValues(t, 100, LFS.MaxBatchSize)
117
-
assert.EqualValues(t, 20, LFSClient.BatchSize)
118
-
assert.EqualValues(t, 8, LFSClient.BatchOperationConcurrency)
116
+
assert.Equal(t, 100, LFS.MaxBatchSize)
117
+
assert.Equal(t, 20, LFSClient.BatchSize)
118
+
assert.Equal(t, 8, LFSClient.BatchOperationConcurrency)
119
119
120
120
iniStr = `
121
121
[lfs_client]
···
126
126
assert.NoError(t, err)
127
127
128
128
assert.NoError(t, loadLFSFrom(cfg))
129
-
assert.EqualValues(t, 50, LFSClient.BatchSize)
130
-
assert.EqualValues(t, 10, LFSClient.BatchOperationConcurrency)
129
+
assert.Equal(t, 50, LFSClient.BatchSize)
130
+
assert.Equal(t, 10, LFSClient.BatchOperationConcurrency)
131
131
}
+4
-4
modules/setting/mailer_test.go
+4
-4
modules/setting/mailer_test.go
···
34
34
// Check mailer setting
35
35
loadMailerFrom(cfg)
36
36
37
-
assert.EqualValues(t, kase.SMTPAddr, MailService.SMTPAddr)
38
-
assert.EqualValues(t, kase.SMTPPort, MailService.SMTPPort)
37
+
assert.Equal(t, kase.SMTPAddr, MailService.SMTPAddr)
38
+
assert.Equal(t, kase.SMTPPort, MailService.SMTPPort)
39
39
})
40
40
}
41
41
···
48
48
49
49
loadMailerFrom(cfg)
50
50
51
-
assert.EqualValues(t, "jane.doe@example.com", MailService.User)
52
-
assert.EqualValues(t, "y0u'll n3v3r gUess th1S!!1", MailService.Passwd)
51
+
assert.Equal(t, "jane.doe@example.com", MailService.User)
52
+
assert.Equal(t, "y0u'll n3v3r gUess th1S!!1", MailService.Passwd)
53
53
})
54
54
}
+1
-1
modules/setting/oauth2_test.go
+1
-1
modules/setting/oauth2_test.go
···
32
32
actual := GetGeneralTokenSigningSecret()
33
33
expected, _ := generate.DecodeJwtSecret("BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB")
34
34
assert.Len(t, actual, 32)
35
-
assert.EqualValues(t, expected, actual)
35
+
assert.Equal(t, expected, actual)
36
36
}
37
37
38
38
func TestGetGeneralSigningSecretSave(t *testing.T) {
+12
-12
modules/setting/packages_test.go
+12
-12
modules/setting/packages_test.go
···
42
42
require.NoError(t, loadPackagesFrom(cfg))
43
43
44
44
assert.EqualValues(t, "minio", Packages.Storage.Type)
45
-
assert.EqualValues(t, "packages/", Packages.Storage.MinioConfig.BasePath)
45
+
assert.Equal(t, "packages/", Packages.Storage.MinioConfig.BasePath)
46
46
47
47
// we can also configure packages storage directly
48
48
iniStr = `
···
54
54
require.NoError(t, loadPackagesFrom(cfg))
55
55
56
56
assert.EqualValues(t, "minio", Packages.Storage.Type)
57
-
assert.EqualValues(t, "packages/", Packages.Storage.MinioConfig.BasePath)
57
+
assert.Equal(t, "packages/", Packages.Storage.MinioConfig.BasePath)
58
58
59
59
// or we can indicate the storage type in the packages section
60
60
iniStr = `
···
69
69
require.NoError(t, loadPackagesFrom(cfg))
70
70
71
71
assert.EqualValues(t, "minio", Packages.Storage.Type)
72
-
assert.EqualValues(t, "packages/", Packages.Storage.MinioConfig.BasePath)
72
+
assert.Equal(t, "packages/", Packages.Storage.MinioConfig.BasePath)
73
73
74
74
// or we can indicate the storage type and minio base path in the packages section
75
75
iniStr = `
···
85
85
require.NoError(t, loadPackagesFrom(cfg))
86
86
87
87
assert.EqualValues(t, "minio", Packages.Storage.Type)
88
-
assert.EqualValues(t, "my_packages/", Packages.Storage.MinioConfig.BasePath)
88
+
assert.Equal(t, "my_packages/", Packages.Storage.MinioConfig.BasePath)
89
89
}
90
90
91
91
func Test_PackageStorage1(t *testing.T) {
···
110
110
storage := Packages.Storage
111
111
112
112
assert.EqualValues(t, "minio", storage.Type)
113
-
assert.EqualValues(t, "gitea", storage.MinioConfig.Bucket)
114
-
assert.EqualValues(t, "packages/", storage.MinioConfig.BasePath)
113
+
assert.Equal(t, "gitea", storage.MinioConfig.Bucket)
114
+
assert.Equal(t, "packages/", storage.MinioConfig.BasePath)
115
115
assert.True(t, storage.MinioConfig.ServeDirect)
116
116
}
117
117
···
137
137
storage := Packages.Storage
138
138
139
139
assert.EqualValues(t, "minio", storage.Type)
140
-
assert.EqualValues(t, "gitea", storage.MinioConfig.Bucket)
141
-
assert.EqualValues(t, "packages/", storage.MinioConfig.BasePath)
140
+
assert.Equal(t, "gitea", storage.MinioConfig.Bucket)
141
+
assert.Equal(t, "packages/", storage.MinioConfig.BasePath)
142
142
assert.True(t, storage.MinioConfig.ServeDirect)
143
143
}
144
144
···
165
165
storage := Packages.Storage
166
166
167
167
assert.EqualValues(t, "minio", storage.Type)
168
-
assert.EqualValues(t, "gitea", storage.MinioConfig.Bucket)
169
-
assert.EqualValues(t, "my_packages/", storage.MinioConfig.BasePath)
168
+
assert.Equal(t, "gitea", storage.MinioConfig.Bucket)
169
+
assert.Equal(t, "my_packages/", storage.MinioConfig.BasePath)
170
170
assert.True(t, storage.MinioConfig.ServeDirect)
171
171
}
172
172
···
193
193
storage := Packages.Storage
194
194
195
195
assert.EqualValues(t, "minio", storage.Type)
196
-
assert.EqualValues(t, "gitea", storage.MinioConfig.Bucket)
197
-
assert.EqualValues(t, "my_packages/", storage.MinioConfig.BasePath)
196
+
assert.Equal(t, "gitea", storage.MinioConfig.Bucket)
197
+
assert.Equal(t, "my_packages/", storage.MinioConfig.BasePath)
198
198
assert.True(t, storage.MinioConfig.ServeDirect)
199
199
}
+6
-6
modules/setting/repository_archive_test.go
+6
-6
modules/setting/repository_archive_test.go
···
21
21
require.NoError(t, loadRepoArchiveFrom(cfg))
22
22
23
23
assert.EqualValues(t, "minio", RepoArchive.Storage.Type)
24
-
assert.EqualValues(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
24
+
assert.Equal(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
25
25
26
26
// we can also configure packages storage directly
27
27
iniStr = `
···
33
33
require.NoError(t, loadRepoArchiveFrom(cfg))
34
34
35
35
assert.EqualValues(t, "minio", RepoArchive.Storage.Type)
36
-
assert.EqualValues(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
36
+
assert.Equal(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
37
37
38
38
// or we can indicate the storage type in the packages section
39
39
iniStr = `
···
48
48
require.NoError(t, loadRepoArchiveFrom(cfg))
49
49
50
50
assert.EqualValues(t, "minio", RepoArchive.Storage.Type)
51
-
assert.EqualValues(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
51
+
assert.Equal(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
52
52
53
53
// or we can indicate the storage type and minio base path in the packages section
54
54
iniStr = `
···
64
64
require.NoError(t, loadRepoArchiveFrom(cfg))
65
65
66
66
assert.EqualValues(t, "minio", RepoArchive.Storage.Type)
67
-
assert.EqualValues(t, "my_archive/", RepoArchive.Storage.MinioConfig.BasePath)
67
+
assert.Equal(t, "my_archive/", RepoArchive.Storage.MinioConfig.BasePath)
68
68
}
69
69
70
70
func Test_RepoArchiveStorage(t *testing.T) {
···
86
86
storage := RepoArchive.Storage
87
87
88
88
assert.EqualValues(t, "minio", storage.Type)
89
-
assert.EqualValues(t, "gitea", storage.MinioConfig.Bucket)
89
+
assert.Equal(t, "gitea", storage.MinioConfig.Bucket)
90
90
91
91
iniStr = `
92
92
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
···
108
108
storage = RepoArchive.Storage
109
109
110
110
assert.EqualValues(t, "minio", storage.Type)
111
-
assert.EqualValues(t, "gitea", storage.MinioConfig.Bucket)
111
+
assert.Equal(t, "gitea", storage.MinioConfig.Bucket)
112
112
}
+1
-1
modules/setting/server_test.go
+1
-1
modules/setting/server_test.go
+1
-1
modules/setting/service.go
+1
-1
modules/setting/service.go
···
206
206
}
207
207
Service.EmailDomainBlockList = append(Service.EmailDomainBlockList, toAdd...)
208
208
}
209
-
Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!(Service.DisableRegistration || Service.AllowOnlyExternalRegistration))
209
+
Service.ShowRegistrationButton = sec.Key("SHOW_REGISTRATION_BUTTON").MustBool(!Service.DisableRegistration && !Service.AllowOnlyExternalRegistration)
210
210
Service.EnableInternalSignIn = sec.Key("ENABLE_INTERNAL_SIGNIN").MustBool(true)
211
211
Service.ShowMilestonesDashboardPage = sec.Key("SHOW_MILESTONES_DASHBOARD_PAGE").MustBool(true)
212
212
Service.RequireSignInView = sec.Key("REQUIRE_SIGNIN_VIEW").MustBool()
+2
-2
modules/setting/storage.go
+2
-2
modules/setting/storage.go
···
170
170
targetSec, _ := rootCfg.GetSection(storageSectionName + "." + name)
171
171
if targetSec != nil {
172
172
targetType := targetSec.Key("STORAGE_TYPE").String()
173
-
switch {
174
-
case targetType == "":
173
+
switch targetType {
174
+
case "":
175
175
if targetSec.Key("PATH").String() == "" { // both storage type and path are empty, use default
176
176
return getDefaultStorageSection(rootCfg), targetSecIsDefault, nil
177
177
}
+37
-37
modules/setting/storage_test.go
+37
-37
modules/setting/storage_test.go
···
27
27
require.NoError(t, err)
28
28
29
29
require.NoError(t, loadAttachmentFrom(cfg))
30
-
assert.EqualValues(t, "gitea-attachment", Attachment.Storage.MinioConfig.Bucket)
31
-
assert.EqualValues(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
30
+
assert.Equal(t, "gitea-attachment", Attachment.Storage.MinioConfig.Bucket)
31
+
assert.Equal(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
32
32
33
33
require.NoError(t, loadLFSFrom(cfg))
34
-
assert.EqualValues(t, "gitea-lfs", LFS.Storage.MinioConfig.Bucket)
35
-
assert.EqualValues(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
34
+
assert.Equal(t, "gitea-lfs", LFS.Storage.MinioConfig.Bucket)
35
+
assert.Equal(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
36
36
37
37
require.NoError(t, loadAvatarsFrom(cfg))
38
-
assert.EqualValues(t, "gitea-storage", Avatar.Storage.MinioConfig.Bucket)
39
-
assert.EqualValues(t, "avatars/", Avatar.Storage.MinioConfig.BasePath)
38
+
assert.Equal(t, "gitea-storage", Avatar.Storage.MinioConfig.Bucket)
39
+
assert.Equal(t, "avatars/", Avatar.Storage.MinioConfig.BasePath)
40
40
}
41
41
42
42
func Test_getStorageUseOtherNameAsType(t *testing.T) {
···
52
52
require.NoError(t, err)
53
53
54
54
require.NoError(t, loadAttachmentFrom(cfg))
55
-
assert.EqualValues(t, "gitea-storage", Attachment.Storage.MinioConfig.Bucket)
56
-
assert.EqualValues(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
55
+
assert.Equal(t, "gitea-storage", Attachment.Storage.MinioConfig.Bucket)
56
+
assert.Equal(t, "attachments/", Attachment.Storage.MinioConfig.BasePath)
57
57
58
58
require.NoError(t, loadLFSFrom(cfg))
59
-
assert.EqualValues(t, "gitea-storage", LFS.Storage.MinioConfig.Bucket)
60
-
assert.EqualValues(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
59
+
assert.Equal(t, "gitea-storage", LFS.Storage.MinioConfig.Bucket)
60
+
assert.Equal(t, "lfs/", LFS.Storage.MinioConfig.BasePath)
61
61
}
62
62
63
63
func Test_getStorageInheritStorageType(t *testing.T) {
···
70
70
71
71
require.NoError(t, loadPackagesFrom(cfg))
72
72
assert.EqualValues(t, "minio", Packages.Storage.Type)
73
-
assert.EqualValues(t, "gitea", Packages.Storage.MinioConfig.Bucket)
74
-
assert.EqualValues(t, "packages/", Packages.Storage.MinioConfig.BasePath)
73
+
assert.Equal(t, "gitea", Packages.Storage.MinioConfig.Bucket)
74
+
assert.Equal(t, "packages/", Packages.Storage.MinioConfig.BasePath)
75
75
76
76
require.NoError(t, loadRepoArchiveFrom(cfg))
77
77
assert.EqualValues(t, "minio", RepoArchive.Storage.Type)
78
-
assert.EqualValues(t, "gitea", RepoArchive.Storage.MinioConfig.Bucket)
79
-
assert.EqualValues(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
78
+
assert.Equal(t, "gitea", RepoArchive.Storage.MinioConfig.Bucket)
79
+
assert.Equal(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
80
80
81
81
require.NoError(t, loadActionsFrom(cfg))
82
82
assert.EqualValues(t, "minio", Actions.LogStorage.Type)
83
-
assert.EqualValues(t, "gitea", Actions.LogStorage.MinioConfig.Bucket)
84
-
assert.EqualValues(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
83
+
assert.Equal(t, "gitea", Actions.LogStorage.MinioConfig.Bucket)
84
+
assert.Equal(t, "actions_log/", Actions.LogStorage.MinioConfig.BasePath)
85
85
86
86
assert.EqualValues(t, "minio", Actions.ArtifactStorage.Type)
87
-
assert.EqualValues(t, "gitea", Actions.ArtifactStorage.MinioConfig.Bucket)
88
-
assert.EqualValues(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
87
+
assert.Equal(t, "gitea", Actions.ArtifactStorage.MinioConfig.Bucket)
88
+
assert.Equal(t, "actions_artifacts/", Actions.ArtifactStorage.MinioConfig.BasePath)
89
89
90
90
require.NoError(t, loadAvatarsFrom(cfg))
91
91
assert.EqualValues(t, "minio", Avatar.Storage.Type)
92
-
assert.EqualValues(t, "gitea", Avatar.Storage.MinioConfig.Bucket)
93
-
assert.EqualValues(t, "avatars/", Avatar.Storage.MinioConfig.BasePath)
92
+
assert.Equal(t, "gitea", Avatar.Storage.MinioConfig.Bucket)
93
+
assert.Equal(t, "avatars/", Avatar.Storage.MinioConfig.BasePath)
94
94
95
95
require.NoError(t, loadRepoAvatarFrom(cfg))
96
96
assert.EqualValues(t, "minio", RepoAvatar.Storage.Type)
97
-
assert.EqualValues(t, "gitea", RepoAvatar.Storage.MinioConfig.Bucket)
98
-
assert.EqualValues(t, "repo-avatars/", RepoAvatar.Storage.MinioConfig.BasePath)
97
+
assert.Equal(t, "gitea", RepoAvatar.Storage.MinioConfig.Bucket)
98
+
assert.Equal(t, "repo-avatars/", RepoAvatar.Storage.MinioConfig.BasePath)
99
99
}
100
100
101
101
type testLocalStoragePathCase struct {
···
114
114
115
115
assert.EqualValues(t, "local", storage.Type)
116
116
assert.True(t, filepath.IsAbs(storage.Path))
117
-
assert.EqualValues(t, filepath.Clean(c.expectedPath), filepath.Clean(storage.Path))
117
+
assert.Equal(t, filepath.Clean(c.expectedPath), filepath.Clean(storage.Path))
118
118
}
119
119
}
120
120
···
352
352
353
353
require.NoError(t, loadRepoArchiveFrom(cfg))
354
354
cp := RepoArchive.Storage.ToShadowCopy()
355
-
assert.EqualValues(t, "******", cp.MinioConfig.AccessKeyID)
356
-
assert.EqualValues(t, "******", cp.MinioConfig.SecretAccessKey)
355
+
assert.Equal(t, "******", cp.MinioConfig.AccessKeyID)
356
+
assert.Equal(t, "******", cp.MinioConfig.SecretAccessKey)
357
357
}
358
358
359
359
func Test_getStorageConfiguration24(t *testing.T) {
···
408
408
`)
409
409
require.NoError(t, err)
410
410
require.NoError(t, loadRepoArchiveFrom(cfg))
411
-
assert.EqualValues(t, "my_access_key", RepoArchive.Storage.MinioConfig.AccessKeyID)
412
-
assert.EqualValues(t, "my_secret_key", RepoArchive.Storage.MinioConfig.SecretAccessKey)
411
+
assert.Equal(t, "my_access_key", RepoArchive.Storage.MinioConfig.AccessKeyID)
412
+
assert.Equal(t, "my_secret_key", RepoArchive.Storage.MinioConfig.SecretAccessKey)
413
413
assert.True(t, RepoArchive.Storage.MinioConfig.UseSSL)
414
-
assert.EqualValues(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
414
+
assert.Equal(t, "repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
415
415
}
416
416
417
417
func Test_getStorageConfiguration28(t *testing.T) {
···
425
425
`)
426
426
require.NoError(t, err)
427
427
require.NoError(t, loadRepoArchiveFrom(cfg))
428
-
assert.EqualValues(t, "my_access_key", RepoArchive.Storage.MinioConfig.AccessKeyID)
429
-
assert.EqualValues(t, "my_secret_key", RepoArchive.Storage.MinioConfig.SecretAccessKey)
428
+
assert.Equal(t, "my_access_key", RepoArchive.Storage.MinioConfig.AccessKeyID)
429
+
assert.Equal(t, "my_secret_key", RepoArchive.Storage.MinioConfig.SecretAccessKey)
430
430
assert.True(t, RepoArchive.Storage.MinioConfig.UseSSL)
431
-
assert.EqualValues(t, "/prefix/repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
431
+
assert.Equal(t, "/prefix/repo-archive/", RepoArchive.Storage.MinioConfig.BasePath)
432
432
433
433
cfg, err = NewConfigProviderFromData(`
434
434
[storage]
···
443
443
`)
444
444
require.NoError(t, err)
445
445
require.NoError(t, loadLFSFrom(cfg))
446
-
assert.EqualValues(t, "my_access_key", LFS.Storage.MinioConfig.AccessKeyID)
447
-
assert.EqualValues(t, "my_secret_key", LFS.Storage.MinioConfig.SecretAccessKey)
446
+
assert.Equal(t, "my_access_key", LFS.Storage.MinioConfig.AccessKeyID)
447
+
assert.Equal(t, "my_secret_key", LFS.Storage.MinioConfig.SecretAccessKey)
448
448
assert.True(t, LFS.Storage.MinioConfig.UseSSL)
449
-
assert.EqualValues(t, "/lfs", LFS.Storage.MinioConfig.BasePath)
449
+
assert.Equal(t, "/lfs", LFS.Storage.MinioConfig.BasePath)
450
450
451
451
cfg, err = NewConfigProviderFromData(`
452
452
[storage]
···
461
461
`)
462
462
require.NoError(t, err)
463
463
require.NoError(t, loadLFSFrom(cfg))
464
-
assert.EqualValues(t, "my_access_key", LFS.Storage.MinioConfig.AccessKeyID)
465
-
assert.EqualValues(t, "my_secret_key", LFS.Storage.MinioConfig.SecretAccessKey)
464
+
assert.Equal(t, "my_access_key", LFS.Storage.MinioConfig.AccessKeyID)
465
+
assert.Equal(t, "my_secret_key", LFS.Storage.MinioConfig.SecretAccessKey)
466
466
assert.True(t, LFS.Storage.MinioConfig.UseSSL)
467
-
assert.EqualValues(t, "/lfs", LFS.Storage.MinioConfig.BasePath)
467
+
assert.Equal(t, "/lfs", LFS.Storage.MinioConfig.BasePath)
468
468
}
+1
-1
modules/storage/local_test.go
+1
-1
modules/storage/local_test.go
+2
-2
modules/storage/minio.go
+2
-2
modules/storage/minio.go
···
231
231
}
232
232
233
233
func (m minioFileInfo) Name() string {
234
-
return path.Base(m.ObjectInfo.Key)
234
+
return path.Base(m.Key)
235
235
}
236
236
237
237
func (m minioFileInfo) Size() int64 {
···
243
243
}
244
244
245
245
func (m minioFileInfo) IsDir() bool {
246
-
return strings.HasSuffix(m.ObjectInfo.Key, "/")
246
+
return strings.HasSuffix(m.Key, "/")
247
247
}
248
248
249
249
func (m minioFileInfo) Mode() os.FileMode {
+6
-6
modules/storage/minio_test.go
+6
-6
modules/storage/minio_test.go
···
52
52
53
53
func TestMinioStoragePath(t *testing.T) {
54
54
m := &MinioStorage{basePath: ""}
55
-
assert.Equal(t, "", m.buildMinioPath("/"))
56
-
assert.Equal(t, "", m.buildMinioPath("."))
55
+
assert.Empty(t, m.buildMinioPath("/"))
56
+
assert.Empty(t, m.buildMinioPath("."))
57
57
assert.Equal(t, "a", m.buildMinioPath("/a"))
58
58
assert.Equal(t, "a/b", m.buildMinioPath("/a/b/"))
59
-
assert.Equal(t, "", m.buildMinioDirPrefix(""))
59
+
assert.Empty(t, m.buildMinioDirPrefix(""))
60
60
assert.Equal(t, "a/", m.buildMinioDirPrefix("/a/"))
61
61
62
62
m = &MinioStorage{basePath: "/"}
63
-
assert.Equal(t, "", m.buildMinioPath("/"))
64
-
assert.Equal(t, "", m.buildMinioPath("."))
63
+
assert.Empty(t, m.buildMinioPath("/"))
64
+
assert.Empty(t, m.buildMinioPath("."))
65
65
assert.Equal(t, "a", m.buildMinioPath("/a"))
66
66
assert.Equal(t, "a/b", m.buildMinioPath("/a/b/"))
67
-
assert.Equal(t, "", m.buildMinioDirPrefix(""))
67
+
assert.Empty(t, m.buildMinioDirPrefix(""))
68
68
assert.Equal(t, "a/", m.buildMinioDirPrefix("/a/"))
69
69
70
70
m = &MinioStorage{basePath: "/base"}
+4
-4
modules/structs/repo_file.go
+4
-4
modules/structs/repo_file.go
···
31
31
32
32
// Branch returns branch name
33
33
func (o *CreateFileOptions) Branch() string {
34
-
return o.FileOptions.BranchName
34
+
return o.BranchName
35
35
}
36
36
37
37
// DeleteFileOptions options for deleting files (used for other File structs below)
···
45
45
46
46
// Branch returns branch name
47
47
func (o *DeleteFileOptions) Branch() string {
48
-
return o.FileOptions.BranchName
48
+
return o.BranchName
49
49
}
50
50
51
51
// UpdateFileOptions options for updating files
···
61
61
62
62
// Branch returns branch name
63
63
func (o *UpdateFileOptions) Branch() string {
64
-
return o.FileOptions.BranchName
64
+
return o.BranchName
65
65
}
66
66
67
67
// ChangeFileOperation for creating, updating or deleting a file
···
92
92
93
93
// Branch returns branch name
94
94
func (o *ChangeFilesOptions) Branch() string {
95
-
return o.FileOptions.BranchName
95
+
return o.BranchName
96
96
}
97
97
98
98
// FileOptionInterface provides a unified interface for the different file options
+3
-3
modules/system/appstate_test.go
+3
-3
modules/system/appstate_test.go
···
43
43
44
44
item1 := new(testItem1)
45
45
require.NoError(t, as.Get(db.DefaultContext, item1))
46
-
assert.Equal(t, "", item1.Val1)
47
-
assert.EqualValues(t, 0, item1.Val2)
46
+
assert.Empty(t, item1.Val1)
47
+
assert.Equal(t, 0, item1.Val2)
48
48
49
49
item1 = new(testItem1)
50
50
item1.Val1 = "a"
···
58
58
item1 = new(testItem1)
59
59
require.NoError(t, as.Get(db.DefaultContext, item1))
60
60
assert.Equal(t, "a", item1.Val1)
61
-
assert.EqualValues(t, 2, item1.Val2)
61
+
assert.Equal(t, 2, item1.Val2)
62
62
63
63
item2 = new(testItem2)
64
64
require.NoError(t, as.Get(db.DefaultContext, item2))
+2
-2
modules/templates/htmlrenderer_test.go
+2
-2
modules/templates/htmlrenderer_test.go
···
66
66
_, err = tmpl.Parse(s)
67
67
require.Error(t, err)
68
68
msg := h(err)
69
-
assert.EqualValues(t, strings.TrimSpace(expect), strings.TrimSpace(msg))
69
+
assert.Equal(t, strings.TrimSpace(expect), strings.TrimSpace(msg))
70
70
}
71
71
72
72
test("{{", p.handleGenericTemplateError, `
···
103
103
----------------------------------------------------------------------
104
104
`
105
105
actualMsg := p.handleExpectedEndError(errors.New("template: test:1: expected end; found XXX"))
106
-
assert.EqualValues(t, strings.TrimSpace(expectedMsg), strings.TrimSpace(actualMsg))
106
+
assert.Equal(t, strings.TrimSpace(expectedMsg), strings.TrimSpace(actualMsg))
107
107
}
+9
-9
modules/templates/scopedtmpl/scopedtmpl.go
+9
-9
modules/templates/scopedtmpl/scopedtmpl.go
···
192
192
collectTemplates(nodeList.Nodes)
193
193
} else if node.Type() == parse.NodeIf {
194
194
nodeIf := node.(*parse.IfNode)
195
-
collectTemplates(nodeIf.BranchNode.List.Nodes)
196
-
if nodeIf.BranchNode.ElseList != nil {
197
-
collectTemplates(nodeIf.BranchNode.ElseList.Nodes)
195
+
collectTemplates(nodeIf.List.Nodes)
196
+
if nodeIf.ElseList != nil {
197
+
collectTemplates(nodeIf.ElseList.Nodes)
198
198
}
199
199
} else if node.Type() == parse.NodeRange {
200
200
nodeRange := node.(*parse.RangeNode)
201
-
collectTemplates(nodeRange.BranchNode.List.Nodes)
202
-
if nodeRange.BranchNode.ElseList != nil {
203
-
collectTemplates(nodeRange.BranchNode.ElseList.Nodes)
201
+
collectTemplates(nodeRange.List.Nodes)
202
+
if nodeRange.ElseList != nil {
203
+
collectTemplates(nodeRange.ElseList.Nodes)
204
204
}
205
205
} else if node.Type() == parse.NodeWith {
206
206
nodeWith := node.(*parse.WithNode)
207
-
collectTemplates(nodeWith.BranchNode.List.Nodes)
208
-
if nodeWith.BranchNode.ElseList != nil {
209
-
collectTemplates(nodeWith.BranchNode.ElseList.Nodes)
207
+
collectTemplates(nodeWith.List.Nodes)
208
+
if nodeWith.ElseList != nil {
209
+
collectTemplates(nodeWith.ElseList.Nodes)
210
210
}
211
211
}
212
212
}
+3
-2
modules/templates/util_misc.go
+3
-2
modules/templates/util_misc.go
···
38
38
} else {
39
39
// if sort arg is in url test if it correlates with column header sort arguments
40
40
// the direction of the arrow should indicate the "current sort order", up means ASC(normal), down means DESC(rev)
41
-
if urlSort == normSort {
41
+
switch urlSort {
42
+
case normSort:
42
43
// the table is sorted with this header normal
43
44
return svg.RenderHTML("octicon-triangle-up", 16)
44
-
} else if urlSort == revSort {
45
+
case revSort:
45
46
// the table is sorted with this header reverse
46
47
return svg.RenderHTML("octicon-triangle-down", 16)
47
48
}
+2
-2
modules/templates/util_render_test.go
+2
-2
modules/templates/util_render_test.go
···
47
47
48
48
func TestApostrophesInMentions(t *testing.T) {
49
49
rendered := RenderMarkdownToHtml(t.Context(), "@mention-user's comment")
50
-
assert.EqualValues(t, template.HTML("<p><a href=\"/mention-user\" class=\"mention\" rel=\"nofollow\">@mention-user</a>'s comment</p>\n"), rendered)
50
+
assert.Equal(t, template.HTML("<p><a href=\"/mention-user\" class=\"mention\" rel=\"nofollow\">@mention-user</a>'s comment</p>\n"), rendered)
51
51
}
52
52
53
53
func TestNonExistantUserMention(t *testing.T) {
54
54
rendered := RenderMarkdownToHtml(t.Context(), "@ThisUserDoesNotExist @mention-user")
55
-
assert.EqualValues(t, template.HTML("<p>@ThisUserDoesNotExist <a href=\"/mention-user\" class=\"mention\" rel=\"nofollow\">@mention-user</a></p>\n"), rendered)
55
+
assert.Equal(t, template.HTML("<p>@ThisUserDoesNotExist <a href=\"/mention-user\" class=\"mention\" rel=\"nofollow\">@mention-user</a></p>\n"), rendered)
56
56
}
57
57
58
58
func TestRenderCommitBody(t *testing.T) {
+1
-1
modules/templates/util_test.go
+1
-1
modules/templates/util_test.go
+1
-1
modules/templates/vars/vars_test.go
+1
-1
modules/templates/vars/vars_test.go
+1
-5
modules/timeutil/since.go
+1
-5
modules/timeutil/since.go
+1
-1
modules/translation/i18n/i18n_test.go
+1
-1
modules/translation/i18n/i18n_test.go
+4
-3
modules/translation/i18n/localestore.go
+4
-3
modules/translation/i18n/localestore.go
···
107
107
case string:
108
108
// Check whether we are adding a plural form to the parent object, or a new nested JSON object.
109
109
110
-
if key == "zero" || key == "one" || key == "two" || key == "few" || key == "many" {
110
+
switch key {
111
+
case "zero", "one", "two", "few", "many":
111
112
locale.newStyleMessages[prefix+PluralFormSeparator+key] = v
112
-
} else if key == "other" {
113
+
case "other":
113
114
locale.newStyleMessages[prefix] = v
114
-
} else {
115
+
default:
115
116
locale.newStyleMessages[fullkey] = v
116
117
}
117
118
+14
-14
modules/translation/translation_test.go
+14
-14
modules/translation/translation_test.go
···
16
16
func TestTrSize(t *testing.T) {
17
17
l := NewLocale("")
18
18
size := int64(1)
19
-
assert.EqualValues(t, "1 munits.data.b", l.TrSize(size).String())
19
+
assert.Equal(t, "1 munits.data.b", l.TrSize(size).String())
20
20
size *= 2048
21
-
assert.EqualValues(t, "2 munits.data.kib", l.TrSize(size).String())
21
+
assert.Equal(t, "2 munits.data.kib", l.TrSize(size).String())
22
22
size *= 2048
23
-
assert.EqualValues(t, "4 munits.data.mib", l.TrSize(size).String())
23
+
assert.Equal(t, "4 munits.data.mib", l.TrSize(size).String())
24
24
size *= 2048
25
-
assert.EqualValues(t, "8 munits.data.gib", l.TrSize(size).String())
25
+
assert.Equal(t, "8 munits.data.gib", l.TrSize(size).String())
26
26
size *= 2048
27
-
assert.EqualValues(t, "16 munits.data.tib", l.TrSize(size).String())
27
+
assert.Equal(t, "16 munits.data.tib", l.TrSize(size).String())
28
28
size *= 2048
29
-
assert.EqualValues(t, "32 munits.data.pib", l.TrSize(size).String())
29
+
assert.Equal(t, "32 munits.data.pib", l.TrSize(size).String())
30
30
size *= 128
31
-
assert.EqualValues(t, "4 munits.data.eib", l.TrSize(size).String())
31
+
assert.Equal(t, "4 munits.data.eib", l.TrSize(size).String())
32
32
}
33
33
34
34
func TestPrettyNumber(t *testing.T) {
···
38
38
allLangMap["id-ID"] = &LangType{Lang: "id-ID", Name: "Bahasa Indonesia"}
39
39
40
40
l := NewLocale("id-ID")
41
-
assert.EqualValues(t, "1.000.000", l.PrettyNumber(1000000))
42
-
assert.EqualValues(t, "1.000.000,1", l.PrettyNumber(1000000.1))
43
-
assert.EqualValues(t, "1.000.000", l.PrettyNumber("1000000"))
44
-
assert.EqualValues(t, "1.000.000", l.PrettyNumber("1000000.0"))
45
-
assert.EqualValues(t, "1.000.000,1", l.PrettyNumber("1000000.1"))
41
+
assert.Equal(t, "1.000.000", l.PrettyNumber(1000000))
42
+
assert.Equal(t, "1.000.000,1", l.PrettyNumber(1000000.1))
43
+
assert.Equal(t, "1.000.000", l.PrettyNumber("1000000"))
44
+
assert.Equal(t, "1.000.000", l.PrettyNumber("1000000.0"))
45
+
assert.Equal(t, "1.000.000,1", l.PrettyNumber("1000000.1"))
46
46
47
47
l = NewLocale("nosuch")
48
-
assert.EqualValues(t, "1,000,000", l.PrettyNumber(1000000))
49
-
assert.EqualValues(t, "1,000,000.1", l.PrettyNumber(1000000.1))
48
+
assert.Equal(t, "1,000,000", l.PrettyNumber(1000000))
49
+
assert.Equal(t, "1,000,000.1", l.PrettyNumber(1000000.1))
50
50
}
51
51
52
52
func TestGetPluralRule(t *testing.T) {
+7
-7
modules/util/paginate_test.go
+7
-7
modules/util/paginate_test.go
···
13
13
stringSlice := []string{"a", "b", "c", "d", "e"}
14
14
result, ok := PaginateSlice(stringSlice, 1, 2).([]string)
15
15
assert.True(t, ok)
16
-
assert.EqualValues(t, []string{"a", "b"}, result)
16
+
assert.Equal(t, []string{"a", "b"}, result)
17
17
18
18
result, ok = PaginateSlice(stringSlice, 100, 2).([]string)
19
19
assert.True(t, ok)
20
-
assert.EqualValues(t, []string{}, result)
20
+
assert.Equal(t, []string{}, result)
21
21
22
22
result, ok = PaginateSlice(stringSlice, 3, 2).([]string)
23
23
assert.True(t, ok)
24
-
assert.EqualValues(t, []string{"e"}, result)
24
+
assert.Equal(t, []string{"e"}, result)
25
25
26
26
result, ok = PaginateSlice(stringSlice, 1, 0).([]string)
27
27
assert.True(t, ok)
28
-
assert.EqualValues(t, []string{"a", "b", "c", "d", "e"}, result)
28
+
assert.Equal(t, []string{"a", "b", "c", "d", "e"}, result)
29
29
30
30
result, ok = PaginateSlice(stringSlice, 1, -1).([]string)
31
31
assert.True(t, ok)
32
-
assert.EqualValues(t, []string{"a", "b", "c", "d", "e"}, result)
32
+
assert.Equal(t, []string{"a", "b", "c", "d", "e"}, result)
33
33
34
34
type Test struct {
35
35
Val int
···
38
38
testVar := []*Test{{Val: 2}, {Val: 3}, {Val: 4}}
39
39
testVar, ok = PaginateSlice(testVar, 1, 50).([]*Test)
40
40
assert.True(t, ok)
41
-
assert.EqualValues(t, []*Test{{Val: 2}, {Val: 3}, {Val: 4}}, testVar)
41
+
assert.Equal(t, []*Test{{Val: 2}, {Val: 3}, {Val: 4}}, testVar)
42
42
43
43
testVar, ok = PaginateSlice(testVar, 2, 2).([]*Test)
44
44
assert.True(t, ok)
45
-
assert.EqualValues(t, []*Test{{Val: 4}}, testVar)
45
+
assert.Equal(t, []*Test{{Val: 4}}, testVar)
46
46
}
+3
-2
modules/util/path.go
+3
-2
modules/util/path.go
+2
-2
modules/util/util_test.go
+2
-2
modules/util/util_test.go
···
272
272
273
273
publicKey, privateKey, err := util.GenerateSSHKeypair()
274
274
require.NoError(t, err)
275
-
assert.EqualValues(t, testPublicKey, string(publicKey))
276
-
assert.EqualValues(t, testPrivateKey, string(privateKey))
275
+
assert.Equal(t, testPublicKey, string(publicKey))
276
+
assert.Equal(t, testPrivateKey, string(privateKey))
277
277
}
278
278
279
279
func TestOptionalArg(t *testing.T) {
+1
-1
modules/validation/email_test.go
+1
-1
modules/validation/email_test.go
+32
-32
modules/web/route_test.go
+32
-32
modules/web/route_test.go
···
23
23
r := NewRoute()
24
24
r.Get("/{username}/{reponame}/{type:issues|pulls}", func(resp http.ResponseWriter, req *http.Request) {
25
25
username := chi.URLParam(req, "username")
26
-
assert.EqualValues(t, "gitea", username)
26
+
assert.Equal(t, "gitea", username)
27
27
reponame := chi.URLParam(req, "reponame")
28
-
assert.EqualValues(t, "gitea", reponame)
28
+
assert.Equal(t, "gitea", reponame)
29
29
tp := chi.URLParam(req, "type")
30
-
assert.EqualValues(t, "issues", tp)
30
+
assert.Equal(t, "issues", tp)
31
31
})
32
32
33
33
req, err := http.NewRequest("GET", "http://localhost:8000/gitea/gitea/issues", nil)
34
34
require.NoError(t, err)
35
35
r.ServeHTTP(recorder, req)
36
-
assert.EqualValues(t, http.StatusOK, recorder.Code)
36
+
assert.Equal(t, http.StatusOK, recorder.Code)
37
37
}
38
38
39
39
func TestRoute2(t *testing.T) {
···
48
48
r.Group("", func() {
49
49
r.Get("/{type:issues|pulls}", func(resp http.ResponseWriter, req *http.Request) {
50
50
username := chi.URLParam(req, "username")
51
-
assert.EqualValues(t, "gitea", username)
51
+
assert.Equal(t, "gitea", username)
52
52
reponame := chi.URLParam(req, "reponame")
53
-
assert.EqualValues(t, "gitea", reponame)
53
+
assert.Equal(t, "gitea", reponame)
54
54
tp := chi.URLParam(req, "type")
55
-
assert.EqualValues(t, "issues", tp)
55
+
assert.Equal(t, "issues", tp)
56
56
hit = 0
57
57
})
58
58
59
59
r.Get("/{type:issues|pulls}/{index}", func(resp http.ResponseWriter, req *http.Request) {
60
60
username := chi.URLParam(req, "username")
61
-
assert.EqualValues(t, "gitea", username)
61
+
assert.Equal(t, "gitea", username)
62
62
reponame := chi.URLParam(req, "reponame")
63
-
assert.EqualValues(t, "gitea", reponame)
63
+
assert.Equal(t, "gitea", reponame)
64
64
tp := chi.URLParam(req, "type")
65
-
assert.EqualValues(t, "issues", tp)
65
+
assert.Equal(t, "issues", tp)
66
66
index := chi.URLParam(req, "index")
67
-
assert.EqualValues(t, "1", index)
67
+
assert.Equal(t, "1", index)
68
68
hit = 1
69
69
})
70
70
}, func(resp http.ResponseWriter, req *http.Request) {
···
77
77
r.Group("/issues/{index}", func() {
78
78
r.Get("/view", func(resp http.ResponseWriter, req *http.Request) {
79
79
username := chi.URLParam(req, "username")
80
-
assert.EqualValues(t, "gitea", username)
80
+
assert.Equal(t, "gitea", username)
81
81
reponame := chi.URLParam(req, "reponame")
82
-
assert.EqualValues(t, "gitea", reponame)
82
+
assert.Equal(t, "gitea", reponame)
83
83
index := chi.URLParam(req, "index")
84
-
assert.EqualValues(t, "1", index)
84
+
assert.Equal(t, "1", index)
85
85
hit = 2
86
86
})
87
87
})
···
90
90
req, err := http.NewRequest("GET", "http://localhost:8000/gitea/gitea/issues", nil)
91
91
require.NoError(t, err)
92
92
r.ServeHTTP(recorder, req)
93
-
assert.EqualValues(t, http.StatusOK, recorder.Code)
94
-
assert.EqualValues(t, 0, hit)
93
+
assert.Equal(t, http.StatusOK, recorder.Code)
94
+
assert.Equal(t, 0, hit)
95
95
96
96
req, err = http.NewRequest("GET", "http://localhost:8000/gitea/gitea/issues/1", nil)
97
97
require.NoError(t, err)
98
98
r.ServeHTTP(recorder, req)
99
-
assert.EqualValues(t, http.StatusOK, recorder.Code)
100
-
assert.EqualValues(t, 1, hit)
99
+
assert.Equal(t, http.StatusOK, recorder.Code)
100
+
assert.Equal(t, 1, hit)
101
101
102
102
req, err = http.NewRequest("GET", "http://localhost:8000/gitea/gitea/issues/1?stop=100", nil)
103
103
require.NoError(t, err)
104
104
r.ServeHTTP(recorder, req)
105
-
assert.EqualValues(t, http.StatusOK, recorder.Code)
106
-
assert.EqualValues(t, 100, hit)
105
+
assert.Equal(t, http.StatusOK, recorder.Code)
106
+
assert.Equal(t, 100, hit)
107
107
108
108
req, err = http.NewRequest("GET", "http://localhost:8000/gitea/gitea/issues/1/view", nil)
109
109
require.NoError(t, err)
110
110
r.ServeHTTP(recorder, req)
111
-
assert.EqualValues(t, http.StatusOK, recorder.Code)
112
-
assert.EqualValues(t, 2, hit)
111
+
assert.Equal(t, http.StatusOK, recorder.Code)
112
+
assert.Equal(t, 2, hit)
113
113
}
114
114
115
115
func TestRoute3(t *testing.T) {
···
150
150
req, err := http.NewRequest("GET", "http://localhost:8000/api/v1/repos/gitea/gitea/branch_protections", nil)
151
151
require.NoError(t, err)
152
152
r.ServeHTTP(recorder, req)
153
-
assert.EqualValues(t, http.StatusOK, recorder.Code)
154
-
assert.EqualValues(t, 0, hit)
153
+
assert.Equal(t, http.StatusOK, recorder.Code)
154
+
assert.Equal(t, 0, hit)
155
155
156
156
req, err = http.NewRequest("POST", "http://localhost:8000/api/v1/repos/gitea/gitea/branch_protections", nil)
157
157
require.NoError(t, err)
158
158
r.ServeHTTP(recorder, req)
159
-
assert.EqualValues(t, http.StatusOK, recorder.Code, http.StatusOK)
160
-
assert.EqualValues(t, 1, hit)
159
+
assert.Equal(t, http.StatusOK, recorder.Code, http.StatusOK)
160
+
assert.Equal(t, 1, hit)
161
161
162
162
req, err = http.NewRequest("GET", "http://localhost:8000/api/v1/repos/gitea/gitea/branch_protections/master", nil)
163
163
require.NoError(t, err)
164
164
r.ServeHTTP(recorder, req)
165
-
assert.EqualValues(t, http.StatusOK, recorder.Code)
166
-
assert.EqualValues(t, 2, hit)
165
+
assert.Equal(t, http.StatusOK, recorder.Code)
166
+
assert.Equal(t, 2, hit)
167
167
168
168
req, err = http.NewRequest("PATCH", "http://localhost:8000/api/v1/repos/gitea/gitea/branch_protections/master", nil)
169
169
require.NoError(t, err)
170
170
r.ServeHTTP(recorder, req)
171
-
assert.EqualValues(t, http.StatusOK, recorder.Code)
172
-
assert.EqualValues(t, 3, hit)
171
+
assert.Equal(t, http.StatusOK, recorder.Code)
172
+
assert.Equal(t, 3, hit)
173
173
174
174
req, err = http.NewRequest("DELETE", "http://localhost:8000/api/v1/repos/gitea/gitea/branch_protections/master", nil)
175
175
require.NoError(t, err)
176
176
r.ServeHTTP(recorder, req)
177
-
assert.EqualValues(t, http.StatusOK, recorder.Code)
178
-
assert.EqualValues(t, 4, hit)
177
+
assert.Equal(t, http.StatusOK, recorder.Code)
178
+
assert.Equal(t, 4, hit)
179
179
}
+8
-8
modules/web/routemock_test.go
+8
-8
modules/web/routemock_test.go
···
35
35
require.NoError(t, err)
36
36
r.ServeHTTP(recorder, req)
37
37
assert.Len(t, recorder.Header(), 3)
38
-
assert.EqualValues(t, "m1", recorder.Header().Get("X-Test-Middleware1"))
39
-
assert.EqualValues(t, "m2", recorder.Header().Get("X-Test-Middleware2"))
40
-
assert.EqualValues(t, "h", recorder.Header().Get("X-Test-Handler"))
38
+
assert.Equal(t, "m1", recorder.Header().Get("X-Test-Middleware1"))
39
+
assert.Equal(t, "m2", recorder.Header().Get("X-Test-Middleware2"))
40
+
assert.Equal(t, "h", recorder.Header().Get("X-Test-Handler"))
41
41
RouteMockReset()
42
42
43
43
// mock at "mock-point"
···
50
50
require.NoError(t, err)
51
51
r.ServeHTTP(recorder, req)
52
52
assert.Len(t, recorder.Header(), 2)
53
-
assert.EqualValues(t, "m1", recorder.Header().Get("X-Test-Middleware1"))
54
-
assert.EqualValues(t, "a", recorder.Header().Get("X-Test-MockPoint"))
53
+
assert.Equal(t, "m1", recorder.Header().Get("X-Test-Middleware1"))
54
+
assert.Equal(t, "a", recorder.Header().Get("X-Test-MockPoint"))
55
55
RouteMockReset()
56
56
57
57
// mock at MockAfterMiddlewares
···
64
64
require.NoError(t, err)
65
65
r.ServeHTTP(recorder, req)
66
66
assert.Len(t, recorder.Header(), 3)
67
-
assert.EqualValues(t, "m1", recorder.Header().Get("X-Test-Middleware1"))
68
-
assert.EqualValues(t, "m2", recorder.Header().Get("X-Test-Middleware2"))
69
-
assert.EqualValues(t, "b", recorder.Header().Get("X-Test-MockPoint"))
67
+
assert.Equal(t, "m1", recorder.Header().Get("X-Test-Middleware1"))
68
+
assert.Equal(t, "m2", recorder.Header().Get("X-Test-Middleware2"))
69
+
assert.Equal(t, "b", recorder.Header().Get("X-Test-MockPoint"))
70
70
RouteMockReset()
71
71
}
+2
-2
routers/api/actions/artifactsv4.go
+2
-2
routers/api/actions/artifactsv4.go
···
166
166
mac.Write([]byte(endp))
167
167
mac.Write([]byte(expires))
168
168
mac.Write([]byte(artifactName))
169
-
mac.Write([]byte(fmt.Sprint(taskID)))
170
-
mac.Write([]byte(fmt.Sprint(artifactID)))
169
+
fmt.Fprint(mac, taskID)
170
+
fmt.Fprint(mac, artifactID)
171
171
return mac.Sum(nil)
172
172
}
173
173
+3
-2
routers/api/packages/api.go
+3
-2
routers/api/packages/api.go
···
48
48
if ok { // it's a personal access token but not oauth2 token
49
49
scopeMatched := false
50
50
var err error
51
-
if accessMode == perm.AccessModeRead {
51
+
switch accessMode {
52
+
case perm.AccessModeRead:
52
53
scopeMatched, err = scope.HasScope(auth_model.AccessTokenScopeReadPackage)
53
54
if err != nil {
54
55
ctx.Error(http.StatusInternalServerError, "HasScope", err.Error())
55
56
return
56
57
}
57
-
} else if accessMode == perm.AccessModeWrite {
58
+
case perm.AccessModeWrite:
58
59
scopeMatched, err = scope.HasScope(auth_model.AccessTokenScopeWritePackage)
59
60
if err != nil {
60
61
ctx.Error(http.StatusInternalServerError, "HasScope", err.Error())
+1
-1
routers/api/packages/chef/auth.go
+1
-1
routers/api/packages/chef/auth.go
···
147
147
version := m[1]
148
148
149
149
m = algorithmPattern.FindStringSubmatch(hdr)
150
-
if len(m) == 2 && m[1] != "sha1" && !(m[1] == "sha256" && version == "1.3") {
150
+
if len(m) == 2 && m[1] != "sha1" && (m[1] != "sha256" || version != "1.3") {
151
151
return "", util.NewInvalidArgumentErrorf("unsupported algorithm")
152
152
}
153
153
+1
-1
routers/api/packages/chef/chef.go
+1
-1
routers/api/packages/chef/chef.go
+1
-1
routers/api/packages/nuget/auth.go
+1
-1
routers/api/packages/nuget/auth.go
···
25
25
func (a *Auth) Verify(req *http.Request, w http.ResponseWriter, store auth.DataStore, sess auth.SessionStore) (*user_model.User, error) {
26
26
token, err := auth_model.GetAccessTokenBySHA(req.Context(), req.Header.Get("X-NuGet-ApiKey"))
27
27
if err != nil {
28
-
if !(auth_model.IsErrAccessTokenNotExist(err) || auth_model.IsErrAccessTokenEmpty(err)) {
28
+
if !auth_model.IsErrAccessTokenNotExist(err) && !auth_model.IsErrAccessTokenEmpty(err) {
29
29
log.Error("GetAccessTokenBySHA: %v", err)
30
30
return nil, err
31
31
}
+10
-10
routers/api/v1/api.go
+10
-10
routers/api/v1/api.go
···
203
203
}
204
204
205
205
if task.IsForkPullRequest {
206
-
ctx.Repo.Permission.AccessMode = perm.AccessModeRead
206
+
ctx.Repo.AccessMode = perm.AccessModeRead
207
207
} else {
208
-
ctx.Repo.Permission.AccessMode = perm.AccessModeWrite
208
+
ctx.Repo.AccessMode = perm.AccessModeWrite
209
209
}
210
210
211
211
if err := ctx.Repo.Repository.LoadUnits(ctx); err != nil {
212
212
ctx.Error(http.StatusInternalServerError, "LoadUnits", err)
213
213
return
214
214
}
215
-
ctx.Repo.Permission.Units = ctx.Repo.Repository.Units
216
-
ctx.Repo.Permission.UnitsMode = make(map[unit.Type]perm.AccessMode)
215
+
ctx.Repo.Units = ctx.Repo.Repository.Units
216
+
ctx.Repo.UnitsMode = make(map[unit.Type]perm.AccessMode)
217
217
for _, u := range ctx.Repo.Repository.Units {
218
-
ctx.Repo.Permission.UnitsMode[u.Type] = ctx.Repo.Permission.AccessMode
218
+
ctx.Repo.UnitsMode[u.Type] = ctx.Repo.AccessMode
219
219
}
220
220
} else {
221
221
ctx.Repo.Permission, err = access_model.GetUserRepoPermission(ctx, repo, ctx.Doer)
···
692
692
}
693
693
694
694
func mustAllowPulls(ctx *context.APIContext) {
695
-
if !(ctx.Repo.Repository.CanEnablePulls() && ctx.Repo.CanRead(unit.TypePullRequests)) {
695
+
if !ctx.Repo.Repository.CanEnablePulls() || !ctx.Repo.CanRead(unit.TypePullRequests) {
696
696
if ctx.Repo.Repository.CanEnablePulls() && log.IsTrace() {
697
697
if ctx.IsSigned {
698
698
log.Trace("Permission Denied: User %-v cannot read %-v in Repo %-v\n"+
···
716
716
717
717
func mustEnableIssuesOrPulls(ctx *context.APIContext) {
718
718
if !ctx.Repo.CanRead(unit.TypeIssues) &&
719
-
!(ctx.Repo.Repository.CanEnablePulls() && ctx.Repo.CanRead(unit.TypePullRequests)) {
719
+
(!ctx.Repo.Repository.CanEnablePulls() || !ctx.Repo.CanRead(unit.TypePullRequests)) {
720
720
if ctx.Repo.Repository.CanEnablePulls() && log.IsTrace() {
721
721
if ctx.IsSigned {
722
722
log.Trace("Permission Denied: User %-v cannot read %-v and %-v in Repo %-v\n"+
···
777
777
func individualPermsChecker(ctx *context.APIContext) {
778
778
// org permissions have been checked in context.OrgAssignment(), but individual permissions haven't been checked.
779
779
if ctx.ContextUser.IsIndividual() {
780
-
switch {
781
-
case ctx.ContextUser.Visibility == api.VisibleTypePrivate:
780
+
switch ctx.ContextUser.Visibility {
781
+
case api.VisibleTypePrivate:
782
782
if ctx.Doer == nil || (ctx.ContextUser.ID != ctx.Doer.ID && !ctx.Doer.IsAdmin) {
783
783
ctx.NotFound("Visit Project", nil)
784
784
return
785
785
}
786
-
case ctx.ContextUser.Visibility == api.VisibleTypeLimited:
786
+
case api.VisibleTypeLimited:
787
787
if ctx.Doer == nil {
788
788
ctx.NotFound("Visit Project", nil)
789
789
return
+3
-3
routers/api/v1/repo/branch.go
+3
-3
routers/api/v1/repo/branch.go
···
231
231
ctx.Error(http.StatusInternalServerError, "GetCommit", err)
232
232
return
233
233
}
234
-
} else if len(opt.OldBranchName) > 0 { //nolint
235
-
if ctx.Repo.GitRepo.IsBranchExist(opt.OldBranchName) { //nolint
236
-
oldCommit, err = ctx.Repo.GitRepo.GetBranchCommit(opt.OldBranchName) //nolint
234
+
} else if len(opt.OldBranchName) > 0 { //nolint:staticcheck
235
+
if ctx.Repo.GitRepo.IsBranchExist(opt.OldBranchName) { //nolint:staticcheck
236
+
oldCommit, err = ctx.Repo.GitRepo.GetBranchCommit(opt.OldBranchName) //nolint:staticcheck
237
237
if err != nil {
238
238
ctx.Error(http.StatusInternalServerError, "GetBranchCommit", err)
239
239
return
+1
-1
routers/api/v1/repo/file.go
+1
-1
routers/api/v1/repo/file.go
···
437
437
438
438
// canReadFiles returns true if repository is readable and user has proper access level.
439
439
func canReadFiles(r *context.Repository) bool {
440
-
return r.Permission.CanRead(unit.TypeCode)
440
+
return r.CanRead(unit.TypeCode)
441
441
}
442
442
443
443
func base64Reader(s string) (io.ReadSeeker, error) {
+1
-1
routers/api/v1/repo/hook_test.go
+1
-1
routers/api/v1/repo/hook_test.go
···
25
25
defer ctx.Repo.GitRepo.Close()
26
26
contexttest.LoadRepoCommit(t, ctx)
27
27
TestHook(ctx)
28
-
assert.EqualValues(t, http.StatusNoContent, ctx.Resp.Status())
28
+
assert.Equal(t, http.StatusNoContent, ctx.Resp.Status())
29
29
30
30
unittest.AssertExistsAndLoadBean(t, &webhook.HookTask{
31
31
HookID: 1,
+11
-11
routers/api/v1/repo/issue_dependency.go
+11
-11
routers/api/v1/repo/issue_dependency.go
···
72
72
}
73
73
74
74
// 1. We must be able to read this issue
75
-
if !ctx.Repo.Permission.CanReadIssuesOrPulls(issue.IsPull) {
75
+
if !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull) {
76
76
ctx.NotFound()
77
77
return
78
78
}
···
88
88
limit = setting.API.MaxResponseItems
89
89
}
90
90
91
-
canWrite := ctx.Repo.Permission.CanWriteIssuesOrPulls(issue.IsPull)
91
+
canWrite := ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull)
92
92
93
93
blockerIssues := make([]*issues_model.Issue, 0, limit)
94
94
···
123
123
}
124
124
125
125
// check permission
126
-
if !perm.CanReadIssuesOrPulls(blocker.Issue.IsPull) {
126
+
if !perm.CanReadIssuesOrPulls(blocker.IsPull) {
127
127
if !canWrite {
128
128
hiddenBlocker := &issues_model.DependencyInfo{
129
129
Issue: issues_model.Issue{
···
134
134
} else {
135
135
confidentialBlocker := &issues_model.DependencyInfo{
136
136
Issue: issues_model.Issue{
137
-
RepoID: blocker.Issue.RepoID,
137
+
RepoID: blocker.RepoID,
138
138
Index: blocker.Index,
139
139
Title: blocker.Title,
140
140
IsClosed: blocker.IsClosed,
141
141
IsPull: blocker.IsPull,
142
142
},
143
143
Repository: repo_model.Repository{
144
-
ID: blocker.Issue.Repo.ID,
145
-
Name: blocker.Issue.Repo.Name,
146
-
OwnerName: blocker.Issue.Repo.OwnerName,
144
+
ID: blocker.Repo.ID,
145
+
Name: blocker.Repo.Name,
146
+
OwnerName: blocker.Repo.OwnerName,
147
147
},
148
148
}
149
-
confidentialBlocker.Issue.Repo = &confidentialBlocker.Repository
149
+
confidentialBlocker.Repo = &confidentialBlocker.Repository
150
150
blocker = confidentialBlocker
151
151
}
152
152
}
···
323
323
return
324
324
}
325
325
326
-
if !ctx.Repo.Permission.CanReadIssuesOrPulls(issue.IsPull) {
326
+
if !ctx.Repo.CanReadIssuesOrPulls(issue.IsPull) {
327
327
ctx.NotFound()
328
328
return
329
329
}
···
373
373
repoPerms[depMeta.RepoID] = perm
374
374
}
375
375
376
-
if !perm.CanReadIssuesOrPulls(depMeta.Issue.IsPull) {
376
+
if !perm.CanReadIssuesOrPulls(depMeta.IsPull) {
377
377
continue
378
378
}
379
379
380
-
depMeta.Issue.Repo = &depMeta.Repository
380
+
depMeta.Repo = &depMeta.Repository
381
381
issues = append(issues, &depMeta.Issue)
382
382
}
383
383
+2
-2
routers/api/v1/repo/repo_test.go
+2
-2
routers/api/v1/repo/repo_test.go
···
58
58
web.SetForm(ctx, &opts)
59
59
Edit(ctx)
60
60
61
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
61
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
62
62
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{
63
63
ID: 1,
64
64
}, unittest.Cond("name = ? AND is_archived = 1", *opts.Name))
···
78
78
79
79
web.SetForm(ctx, &opts)
80
80
Edit(ctx)
81
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
81
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
82
82
83
83
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{
84
84
ID: 1,
+4
-3
routers/api/v1/user/key.go
+4
-3
routers/api/v1/user/key.go
···
24
24
25
25
// appendPrivateInformation appends the owner and key type information to api.PublicKey
26
26
func appendPrivateInformation(ctx std_ctx.Context, apiKey *api.PublicKey, key *asymkey_model.PublicKey, defaultUser *user_model.User) (*api.PublicKey, error) {
27
-
if key.Type == asymkey_model.KeyTypeDeploy {
27
+
switch key.Type {
28
+
case asymkey_model.KeyTypeDeploy:
28
29
apiKey.KeyType = "deploy"
29
-
} else if key.Type == asymkey_model.KeyTypeUser {
30
+
case asymkey_model.KeyTypeUser:
30
31
apiKey.KeyType = "user"
31
32
32
33
if defaultUser.ID == key.OwnerID {
···
38
39
}
39
40
apiKey.Owner = convert.ToUser(ctx, user, user)
40
41
}
41
-
} else {
42
+
default:
42
43
apiKey.KeyType = "unknown"
43
44
}
44
45
apiKey.ReadOnly = key.Mode == perm.AccessModeRead
+1
-1
routers/api/v1/user/repo.go
+1
-1
routers/api/v1/user/repo.go
+3
-3
routers/install/routes_test.go
+3
-3
routers/install/routes_test.go
···
19
19
w := httptest.NewRecorder()
20
20
req := httptest.NewRequest("GET", "/", nil)
21
21
r.ServeHTTP(w, req)
22
-
assert.EqualValues(t, 200, w.Code)
22
+
assert.Equal(t, 200, w.Code)
23
23
assert.Contains(t, w.Body.String(), `class="page-content install"`)
24
24
25
25
w = httptest.NewRecorder()
26
26
req = httptest.NewRequest("GET", "/no-such", nil)
27
27
r.ServeHTTP(w, req)
28
-
assert.EqualValues(t, 404, w.Code)
28
+
assert.Equal(t, 404, w.Code)
29
29
30
30
w = httptest.NewRecorder()
31
31
req = httptest.NewRequest("GET", "/assets/img/gitea.svg", nil)
32
32
r.ServeHTTP(w, req)
33
-
assert.EqualValues(t, 200, w.Code)
33
+
assert.Equal(t, 200, w.Code)
34
34
}
35
35
36
36
func TestMain(m *testing.M) {
+1
-1
routers/private/hook_post_receive_test.go
+1
-1
routers/private/hook_post_receive_test.go
···
44
44
pr, err = issues_model.GetPullRequestByID(db.DefaultContext, pr.ID)
45
45
require.NoError(t, err)
46
46
assert.True(t, pr.HasMerged)
47
-
assert.EqualValues(t, "01234567", pr.MergedCommitID)
47
+
assert.Equal(t, "01234567", pr.MergedCommitID)
48
48
49
49
unittest.AssertNotExistsBean(t, &pull_model.AutoMerge{ID: autoMerge.ID})
50
50
}
+2
-5
routers/private/hook_pre_receive.go
+2
-5
routers/private/hook_pre_receive.go
···
155
155
return nil
156
156
}
157
157
158
-
ok, err := quota_model.EvaluateForUser(ctx, ctx.PrivateContext.Repo.Repository.OwnerID, quota_model.LimitSubjectSizeReposAll)
158
+
ok, err := quota_model.EvaluateForUser(ctx, ctx.Repo.Repository.OwnerID, quota_model.LimitSubjectSizeReposAll)
159
159
if err != nil {
160
160
log.Error("quota_model.EvaluateForUser: %v", err)
161
161
ctx.JSON(http.StatusInternalServerError, private.Response{
···
531
531
532
532
baseBranchName := refFullName.ForBranchName()
533
533
534
-
baseBranchExist := false
535
-
if ctx.Repo.GitRepo.IsBranchExist(baseBranchName) {
536
-
baseBranchExist = true
537
-
}
534
+
baseBranchExist := ctx.Repo.GitRepo.IsBranchExist(baseBranchName)
538
535
539
536
if !baseBranchExist {
540
537
for p, v := range baseBranchName {
+1
-1
routers/web/admin/admin_test.go
+1
-1
routers/web/admin/admin_test.go
+3
-2
routers/web/auth/auth.go
+3
-2
routers/web/auth/auth.go
···
512
512
func createUserInContext(ctx *context.Context, tpl base.TplName, form any, u *user_model.User, overwrites *user_model.CreateUserOverwriteOptions, gothUser *goth.User, allowLink bool) (ok bool) {
513
513
if err := user_model.CreateUser(ctx, u, overwrites); err != nil {
514
514
if allowLink && (user_model.IsErrUserAlreadyExist(err) || user_model.IsErrEmailAlreadyUsed(err)) {
515
-
if setting.OAuth2Client.AccountLinking == setting.OAuth2AccountLinkingAuto {
515
+
switch setting.OAuth2Client.AccountLinking {
516
+
case setting.OAuth2AccountLinkingAuto:
516
517
var user *user_model.User
517
518
user = &user_model.User{Name: u.Name}
518
519
hasUser, err := user_model.GetUser(ctx, user)
···
528
529
// TODO: probably we should respect 'remember' user's choice...
529
530
linkAccount(ctx, user, *gothUser, true)
530
531
return false // user is already created here, all redirects are handled
531
-
} else if setting.OAuth2Client.AccountLinking == setting.OAuth2AccountLinkingLogin {
532
+
case setting.OAuth2AccountLinkingLogin:
532
533
showLinkingLogin(ctx, *gothUser)
533
534
return false // user will be created only after linking login
534
535
}
+1
-1
routers/web/auth/oauth_test.go
+1
-1
routers/web/auth/oauth_test.go
···
71
71
assert.Equal(t, "user5", oidcToken.PreferredUsername)
72
72
assert.Equal(t, "https://try.gitea.io/user5", oidcToken.Profile)
73
73
assert.Equal(t, "https://try.gitea.io/assets/img/avatar_default.png", oidcToken.Picture)
74
-
assert.Equal(t, "", oidcToken.Website)
74
+
assert.Empty(t, oidcToken.Website)
75
75
assert.Equal(t, timeutil.TimeStamp(0), oidcToken.UpdatedAt)
76
76
assert.Equal(t, "user5@example.com", oidcToken.Email)
77
77
assert.True(t, oidcToken.EmailVerified)
+2
-2
routers/web/org/members.go
+2
-2
routers/web/org/members.go
···
60
60
}
61
61
62
62
pager := context.NewPagination(int(total), setting.UI.MembersPagingNum, page, 5)
63
-
opts.ListOptions.Page = page
64
-
opts.ListOptions.PageSize = setting.UI.MembersPagingNum
63
+
opts.Page = page
64
+
opts.PageSize = setting.UI.MembersPagingNum
65
65
members, membersIsPublic, err := organization.FindOrgMembers(ctx, opts)
66
66
if err != nil {
67
67
ctx.ServerError("GetMembers", err)
+2
-2
routers/web/repo/action_aggregator_test.go
+2
-2
routers/web/repo/action_aggregator_test.go
···
184
184
cmt := issue.Comments[c]
185
185
t.Logf("%v %v %v\n", cmt.Type, cmt.CreatedUnix, cmt.Content)
186
186
}
187
-
assert.EqualValues(t, len(after), len(issue.Comments))
187
+
assert.Len(t, issue.Comments, len(after))
188
188
t.Fail()
189
189
return
190
190
}
···
214
214
l.AssigneeTeamID = 0
215
215
}
216
216
217
-
assert.EqualValues(t, (after)[c], issue.Comments[c],
217
+
assert.Equal(t, (after)[c], issue.Comments[c],
218
218
"Comment %v is not equal", c,
219
219
)
220
220
}
+1
-1
routers/web/repo/attachment.go
+1
-1
routers/web/repo/attachment.go
···
106
106
}
107
107
108
108
if repository == nil { // If not linked
109
-
if !(ctx.IsSigned && attach.UploaderID == ctx.Doer.ID) { // We block if not the uploader
109
+
if !ctx.IsSigned || attach.UploaderID != ctx.Doer.ID { // We block if not the uploader
110
110
ctx.Error(http.StatusNotFound)
111
111
return
112
112
}
+7
-6
routers/web/repo/compare.go
+7
-6
routers/web/repo/compare.go
···
597
597
config := unit.PullRequestsConfig()
598
598
599
599
if !config.AutodetectManualMerge {
600
-
allowEmptyPr := !(ci.BaseBranch == ci.HeadBranch && ctx.Repo.Repository.Name == ci.HeadRepo.Name)
600
+
allowEmptyPr := ci.BaseBranch != ci.HeadBranch || ctx.Repo.Repository.Name != ci.HeadRepo.Name
601
601
ctx.Data["AllowEmptyPr"] = allowEmptyPr
602
602
603
603
return !allowEmptyPr
···
660
660
661
661
if len(commits) == 1 {
662
662
c := commits[0]
663
-
title = strings.TrimSpace(c.UserCommit.Summary())
663
+
title = strings.TrimSpace(c.Summary())
664
664
665
-
body := strings.Split(strings.TrimSpace(c.UserCommit.Message()), "\n")
665
+
body := strings.Split(strings.TrimSpace(c.Message()), "\n")
666
666
if len(body) > 1 {
667
667
ctx.Data["content"] = strings.Join(body[1:], "\n")
668
668
}
···
952
952
RightHunkSize: rightHunkSize,
953
953
},
954
954
}
955
-
if direction == "up" {
955
+
switch direction {
956
+
case "up":
956
957
section.Lines = append([]*gitdiff.DiffLine{lineSection}, section.Lines...)
957
-
} else if direction == "down" {
958
+
case "down":
958
959
section.Lines = append(section.Lines, lineSection)
959
960
}
960
961
}
···
966
967
}
967
968
968
969
func getExcerptLines(commit *git.Commit, filePath string, idxLeft, idxRight, chunkSize int) ([]*gitdiff.DiffLine, error) {
969
-
blob, err := commit.Tree.GetBlobByPath(filePath)
970
+
blob, err := commit.GetBlobByPath(filePath)
970
971
if err != nil {
971
972
return nil, err
972
973
}
+1
-1
routers/web/repo/editor_test.go
+1
-1
routers/web/repo/editor_test.go
+1
-1
routers/web/repo/githttp_test.go
+1
-1
routers/web/repo/githttp_test.go
+9
-7
routers/web/repo/issue.go
+9
-7
routers/web/repo/issue.go
···
187
187
// 0 means issues with no label
188
188
// blank means labels will not be filtered for issues
189
189
selectLabels := ctx.FormString("labels")
190
-
if selectLabels == "" {
190
+
switch selectLabels {
191
+
case "":
191
192
ctx.Data["AllLabels"] = true
192
-
} else if selectLabels == "0" {
193
+
case "0":
193
194
ctx.Data["NoLabel"] = true
194
195
}
195
196
if len(selectLabels) > 0 {
···
426
427
return 0
427
428
}
428
429
reviewTyp := issues_model.ReviewTypeApprove
429
-
if typ == "reject" {
430
+
switch typ {
431
+
case "reject":
430
432
reviewTyp = issues_model.ReviewTypeReject
431
-
} else if typ == "waiting" {
433
+
case "waiting":
432
434
reviewTyp = issues_model.ReviewTypeRequest
433
435
}
434
436
for _, count := range counts {
···
2128
2130
}
2129
2131
repoPerms[blocker.RepoID] = perm
2130
2132
}
2131
-
if perm.CanReadIssuesOrPulls(blocker.Issue.IsPull) {
2133
+
if perm.CanReadIssuesOrPulls(blocker.IsPull) {
2132
2134
canRead = append(canRead, blocker)
2133
2135
} else {
2134
2136
notPermitted = append(notPermitted, blocker)
···
3117
3119
// Check if issue admin/poster changes the status of issue.
3118
3120
if (ctx.Repo.CanWriteIssuesOrPulls(issue.IsPull) || (ctx.IsSigned && issue.IsPoster(ctx.Doer.ID))) &&
3119
3121
(form.Status == "reopen" || form.Status == "close") &&
3120
-
!(issue.IsPull && issue.PullRequest.HasMerged) {
3122
+
(!issue.IsPull || !issue.PullRequest.HasMerged) {
3121
3123
// Duplication and conflict check should apply to reopen pull request.
3122
3124
var pr *issues_model.PullRequest
3123
3125
···
3632
3634
return
3633
3635
}
3634
3636
3635
-
if !ctx.Repo.Permission.CanReadIssuesOrPulls(comment.Issue.IsPull) {
3637
+
if !ctx.Repo.CanReadIssuesOrPulls(comment.Issue.IsPull) {
3636
3638
ctx.NotFound("CanReadIssuesOrPulls", issues_model.ErrCommentNotExist{})
3637
3639
return
3638
3640
}
+4
-3
routers/web/repo/issue_content_history.go
+4
-3
routers/web/repo/issue_content_history.go
···
160
160
diffHTMLBuf := bytes.Buffer{}
161
161
diffHTMLBuf.WriteString("<pre class='chroma'>")
162
162
for _, it := range diff {
163
-
if it.Type == diffmatchpatch.DiffInsert {
163
+
switch it.Type {
164
+
case diffmatchpatch.DiffInsert:
164
165
diffHTMLBuf.WriteString("<span class='gi'>")
165
166
diffHTMLBuf.WriteString(html.EscapeString(it.Text))
166
167
diffHTMLBuf.WriteString("</span>")
167
-
} else if it.Type == diffmatchpatch.DiffDelete {
168
+
case diffmatchpatch.DiffDelete:
168
169
diffHTMLBuf.WriteString("<span class='gd'>")
169
170
diffHTMLBuf.WriteString(html.EscapeString(it.Text))
170
171
diffHTMLBuf.WriteString("</span>")
171
-
} else {
172
+
default:
172
173
diffHTMLBuf.WriteString(html.EscapeString(it.Text))
173
174
}
174
175
}
+7
-7
routers/web/repo/issue_label_test.go
+7
-7
routers/web/repo/issue_label_test.go
···
39
39
contexttest.LoadRepo(t, ctx, 2)
40
40
web.SetForm(ctx, &forms.InitializeLabelsForm{TemplateName: "Default"})
41
41
InitializeLabels(ctx)
42
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
42
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
43
43
unittest.AssertExistsAndLoadBean(t, &issues_model.Label{
44
44
RepoID: 2,
45
45
Name: "enhancement",
···
69
69
assert.True(t, ok)
70
70
if assert.Len(t, labels, len(testCase.ExpectedLabelIDs)) {
71
71
for i, label := range labels {
72
-
assert.EqualValues(t, testCase.ExpectedLabelIDs[i], label.ID)
72
+
assert.Equal(t, testCase.ExpectedLabelIDs[i], label.ID)
73
73
}
74
74
}
75
75
}
···
85
85
Color: "#abcdef",
86
86
})
87
87
NewLabel(ctx)
88
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
88
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
89
89
unittest.AssertExistsAndLoadBean(t, &issues_model.Label{
90
90
Name: "newlabel",
91
91
Color: "#abcdef",
···
105
105
IsArchived: true,
106
106
})
107
107
UpdateLabel(ctx)
108
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
108
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
109
109
unittest.AssertExistsAndLoadBean(t, &issues_model.Label{
110
110
ID: 2,
111
111
Name: "newnameforlabel",
···
121
121
contexttest.LoadRepo(t, ctx, 1)
122
122
ctx.Req.Form.Set("id", "2")
123
123
DeleteLabel(ctx)
124
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
124
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
125
125
unittest.AssertNotExistsBean(t, &issues_model.Label{ID: 2})
126
126
unittest.AssertNotExistsBean(t, &issues_model.IssueLabel{LabelID: 2})
127
127
assert.EqualValues(t, ctx.Tr("repo.issues.label_deletion_success"), ctx.Flash.SuccessMsg)
···
135
135
ctx.Req.Form.Set("issue_ids", "1,3")
136
136
ctx.Req.Form.Set("action", "clear")
137
137
UpdateIssueLabel(ctx)
138
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
138
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
139
139
unittest.AssertNotExistsBean(t, &issues_model.IssueLabel{IssueID: 1})
140
140
unittest.AssertNotExistsBean(t, &issues_model.IssueLabel{IssueID: 3})
141
141
unittest.CheckConsistencyFor(t, &issues_model.Label{})
···
161
161
ctx.Req.Form.Set("action", testCase.Action)
162
162
ctx.Req.Form.Set("id", strconv.Itoa(int(testCase.LabelID)))
163
163
UpdateIssueLabel(ctx)
164
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
164
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
165
165
for _, issueID := range testCase.IssueIDs {
166
166
unittest.AssertExistsIf(t, testCase.ExpectedAdd, &issues_model.IssueLabel{
167
167
IssueID: issueID,
+5
-5
routers/web/repo/projects.go
+5
-5
routers/web/repo/projects.go
···
120
120
pager.AddParam(ctx, "state", "State")
121
121
ctx.Data["Page"] = pager
122
122
123
-
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
123
+
ctx.Data["CanWriteProjects"] = ctx.Repo.CanWrite(unit.TypeProjects)
124
124
ctx.Data["IsShowClosed"] = isShowClosed
125
125
ctx.Data["IsProjectsPage"] = true
126
126
ctx.Data["SortType"] = sortType
···
146
146
ctx.Data["Title"] = ctx.Tr("repo.projects.new")
147
147
ctx.Data["TemplateConfigs"] = project_model.GetTemplateConfigs()
148
148
ctx.Data["CardTypes"] = project_model.GetCardConfig()
149
-
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
149
+
ctx.Data["CanWriteProjects"] = ctx.Repo.CanWrite(unit.TypeProjects)
150
150
ctx.Data["CancelLink"] = ctx.Repo.Repository.Link() + "/projects"
151
151
ctx.HTML(http.StatusOK, tplProjectsNew)
152
152
}
···
228
228
func RenderEditProject(ctx *context.Context) {
229
229
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
230
230
ctx.Data["PageIsEditProjects"] = true
231
-
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
231
+
ctx.Data["CanWriteProjects"] = ctx.Repo.CanWrite(unit.TypeProjects)
232
232
ctx.Data["CardTypes"] = project_model.GetCardConfig()
233
233
234
234
p, err := project_model.GetProjectByID(ctx, ctx.ParamsInt64(":id"))
···
262
262
263
263
ctx.Data["Title"] = ctx.Tr("repo.projects.edit")
264
264
ctx.Data["PageIsEditProjects"] = true
265
-
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
265
+
ctx.Data["CanWriteProjects"] = ctx.Repo.CanWrite(unit.TypeProjects)
266
266
ctx.Data["CardTypes"] = project_model.GetCardConfig()
267
267
ctx.Data["CancelLink"] = project_model.ProjectLinkForRepo(ctx.Repo.Repository, projectID)
268
268
···
378
378
379
379
ctx.Data["Title"] = project.Title
380
380
ctx.Data["IsProjectsPage"] = true
381
-
ctx.Data["CanWriteProjects"] = ctx.Repo.Permission.CanWrite(unit.TypeProjects)
381
+
ctx.Data["CanWriteProjects"] = ctx.Repo.CanWrite(unit.TypeProjects)
382
382
ctx.Data["Project"] = project
383
383
ctx.Data["IssuesMap"] = issuesMap
384
384
ctx.Data["Columns"] = columns
+2
-2
routers/web/repo/pull.go
+2
-2
routers/web/repo/pull.go
···
892
892
foundStartCommit := len(specifiedStartCommit) == 0
893
893
foundEndCommit := len(specifiedEndCommit) == 0
894
894
895
-
if !(foundStartCommit && foundEndCommit) {
895
+
if !foundStartCommit || !foundEndCommit {
896
896
for _, commit := range prInfo.Commits {
897
897
if commit.ID.String() == specifiedStartCommit {
898
898
foundStartCommit = true
···
907
907
}
908
908
}
909
909
910
-
if !(foundStartCommit && foundEndCommit) {
910
+
if !foundStartCommit || !foundEndCommit {
911
911
ctx.NotFound("Given SHA1 not found for this PR", nil)
912
912
return
913
913
}
+3
-2
routers/web/repo/pull_review.go
+3
-2
routers/web/repo/pull_review.go
···
211
211
return
212
212
}
213
213
ctx.Data["AfterCommitID"] = pullHeadCommitID
214
-
if origin == "diff" {
214
+
switch origin {
215
+
case "diff":
215
216
ctx.HTML(http.StatusOK, tplDiffConversation)
216
-
} else if origin == "timeline" {
217
+
case "timeline":
217
218
ctx.HTML(http.StatusOK, tplTimelineConversation)
218
219
}
219
220
}
+1
-1
routers/web/repo/setting/avatar.go
+1
-1
routers/web/repo/setting/avatar.go
···
46
46
return fmt.Errorf("io.ReadAll: %w", err)
47
47
}
48
48
st := typesniffer.DetectContentType(data)
49
-
if !(st.IsImage() && !st.IsSvgImage()) {
49
+
if !st.IsImage() || st.IsSvgImage() {
50
50
return errors.New(ctx.Locale.TrString("settings.uploaded_avatar_not_a_image"))
51
51
}
52
52
if err = repo_service.UploadAvatar(ctx, ctxRepo, data); err != nil {
+11
-11
routers/web/repo/setting/settings_test.go
+11
-11
routers/web/repo/setting/settings_test.go
···
55
55
}
56
56
web.SetForm(ctx, &addKeyForm)
57
57
DeployKeysPost(ctx)
58
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
58
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
59
59
60
60
unittest.AssertExistsAndLoadBean(t, &asymkey_model.DeployKey{
61
61
Name: addKeyForm.Title,
···
85
85
}
86
86
web.SetForm(ctx, &addKeyForm)
87
87
DeployKeysPost(ctx)
88
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
88
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
89
89
90
90
unittest.AssertExistsAndLoadBean(t, &asymkey_model.DeployKey{
91
91
Name: addKeyForm.Title,
···
124
124
125
125
CollaborationPost(ctx)
126
126
127
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
127
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
128
128
129
129
exists, err := repo_model.IsCollaborator(ctx, re.ID, 4)
130
130
require.NoError(t, err)
···
150
150
151
151
CollaborationPost(ctx)
152
152
153
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
153
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
154
154
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
155
155
}
156
156
···
184
184
185
185
CollaborationPost(ctx)
186
186
187
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
187
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
188
188
189
189
exists, err := repo_model.IsCollaborator(ctx, re.ID, 4)
190
190
require.NoError(t, err)
···
193
193
// Try adding the same collaborator again
194
194
CollaborationPost(ctx)
195
195
196
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
196
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
197
197
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
198
198
}
199
199
···
215
215
216
216
CollaborationPost(ctx)
217
217
218
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
218
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
219
219
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
220
220
}
221
221
···
255
255
AddTeamPost(ctx)
256
256
257
257
assert.True(t, repo_service.HasRepository(db.DefaultContext, team, re.ID))
258
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
258
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
259
259
assert.Empty(t, ctx.Flash.ErrorMsg)
260
260
}
261
261
···
295
295
AddTeamPost(ctx)
296
296
297
297
assert.False(t, repo_service.HasRepository(db.DefaultContext, team, re.ID))
298
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
298
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
299
299
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
300
300
}
301
301
···
336
336
337
337
AddTeamPost(ctx)
338
338
assert.True(t, repo_service.HasRepository(db.DefaultContext, team, re.ID))
339
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
339
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
340
340
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
341
341
}
342
342
···
369
369
ctx.Repo = repo
370
370
371
371
AddTeamPost(ctx)
372
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
372
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
373
373
assert.NotEmpty(t, ctx.Flash.ErrorMsg)
374
374
}
375
375
+12
-12
routers/web/repo/wiki_test.go
+12
-12
routers/web/repo/wiki_test.go
···
73
73
return
74
74
}
75
75
for i, pageMeta := range pageMetas {
76
-
assert.EqualValues(t, expectedNames[i], pageMeta.Name)
76
+
assert.Equal(t, expectedNames[i], pageMeta.Name)
77
77
}
78
78
}
79
79
···
84
84
ctx.SetParams("*", "Home")
85
85
contexttest.LoadRepo(t, ctx, 1)
86
86
Wiki(ctx)
87
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
87
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
88
88
assert.EqualValues(t, "Home", ctx.Data["Title"])
89
89
assertPagesMetas(t, []string{"Home", "Long Page", "Page With Image", "Page With Spaced Name", "Unescaped File", "XSS"}, ctx.Data["Pages"])
90
90
}
···
95
95
ctx, _ := contexttest.MockContext(t, "user2/repo1/wiki/?action=_pages")
96
96
contexttest.LoadRepo(t, ctx, 1)
97
97
WikiPages(ctx)
98
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
98
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
99
99
assertPagesMetas(t, []string{"Home", "Long Page", "Page With Image", "Page With Spaced Name", "Unescaped File", "XSS"}, ctx.Data["Pages"])
100
100
}
101
101
···
106
106
contexttest.LoadUser(t, ctx, 2)
107
107
contexttest.LoadRepo(t, ctx, 1)
108
108
NewWiki(ctx)
109
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
109
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
110
110
assert.EqualValues(t, ctx.Tr("repo.wiki.new_page"), ctx.Data["Title"])
111
111
}
112
112
···
126
126
Message: message,
127
127
})
128
128
NewWikiPost(ctx)
129
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
129
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
130
130
assertWikiExists(t, ctx.Repo.Repository, wiki_service.UserTitleToWebPath("", title))
131
131
assert.Equal(t, content, wikiContent(t, ctx.Repo.Repository, wiki_service.UserTitleToWebPath("", title)))
132
132
}
···
144
144
Message: message,
145
145
})
146
146
NewWikiPost(ctx)
147
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
147
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
148
148
assert.EqualValues(t, ctx.Tr("repo.wiki.reserved_page"), ctx.Flash.ErrorMsg)
149
149
assertWikiNotExists(t, ctx.Repo.Repository, "_edit")
150
150
}
···
157
157
contexttest.LoadUser(t, ctx, 2)
158
158
contexttest.LoadRepo(t, ctx, 1)
159
159
EditWiki(ctx)
160
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
160
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
161
161
assert.EqualValues(t, "Home", ctx.Data["Title"])
162
162
assert.Equal(t, wikiContent(t, ctx.Repo.Repository, "Home"), ctx.Data["content"])
163
163
}
···
178
178
Message: message,
179
179
})
180
180
EditWikiPost(ctx)
181
-
assert.EqualValues(t, http.StatusSeeOther, ctx.Resp.Status())
181
+
assert.Equal(t, http.StatusSeeOther, ctx.Resp.Status())
182
182
assertWikiExists(t, ctx.Repo.Repository, wiki_service.UserTitleToWebPath("", title))
183
183
assert.Equal(t, content, wikiContent(t, ctx.Repo.Repository, wiki_service.UserTitleToWebPath("", title)))
184
184
if title != "Home" {
···
194
194
contexttest.LoadUser(t, ctx, 2)
195
195
contexttest.LoadRepo(t, ctx, 1)
196
196
DeleteWikiPagePost(ctx)
197
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
197
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
198
198
assertWikiNotExists(t, ctx.Repo.Repository, "Home")
199
199
}
200
200
···
215
215
contexttest.LoadRepo(t, ctx, 1)
216
216
WikiRaw(ctx)
217
217
if filetype == "" {
218
-
assert.EqualValues(t, http.StatusNotFound, ctx.Resp.Status(), "filepath: %s", filepath)
218
+
assert.Equal(t, http.StatusNotFound, ctx.Resp.Status(), "filepath: %s", filepath)
219
219
} else {
220
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status(), "filepath: %s", filepath)
221
-
assert.EqualValues(t, filetype, ctx.Resp.Header().Get("Content-Type"), "filepath: %s", filepath)
220
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status(), "filepath: %s", filepath)
221
+
assert.Equal(t, filetype, ctx.Resp.Header().Get("Content-Type"), "filepath: %s", filepath)
222
222
}
223
223
}
224
224
}
+3
-2
routers/web/user/home.go
+3
-2
routers/web/user/home.go
···
655
655
return 0
656
656
}
657
657
reviewTyp := issues_model.ReviewTypeApprove
658
-
if typ == "reject" {
658
+
switch typ {
659
+
case "reject":
659
660
reviewTyp = issues_model.ReviewTypeReject
660
-
} else if typ == "waiting" {
661
+
case "waiting":
661
662
reviewTyp = issues_model.ReviewTypeRequest
662
663
}
663
664
for _, count := range counts {
+13
-13
routers/web/user/home_test.go
+13
-13
routers/web/user/home_test.go
···
40
40
NumIssues[repo.ID] = repo.NumIssues
41
41
}
42
42
assert.False(t, IsArchived[50])
43
-
assert.EqualValues(t, 1, NumIssues[50])
43
+
assert.Equal(t, 1, NumIssues[50])
44
44
assert.True(t, IsArchived[51])
45
-
assert.EqualValues(t, 1, NumIssues[51])
45
+
assert.Equal(t, 1, NumIssues[51])
46
46
47
47
// Act
48
48
Issues(ctx)
49
49
50
50
// Assert: One Issue (ID 30) from one Repo (ID 50) is retrieved, while nothing from archived Repo 51 is retrieved
51
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
51
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
52
52
53
53
assert.Len(t, ctx.Data["Issues"], 1)
54
54
}
···
61
61
contexttest.LoadUser(t, ctx, 2)
62
62
ctx.Req.Form.Set("state", "closed")
63
63
Issues(ctx)
64
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
64
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
65
65
66
66
assert.EqualValues(t, true, ctx.Data["IsShowClosed"])
67
67
assert.Len(t, ctx.Data["Issues"], 1)
···
76
76
ctx.Req.Form.Set("state", "open")
77
77
ctx.Req.Form.Set("type", "your_repositories")
78
78
Pulls(ctx)
79
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
79
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
80
80
81
81
assert.Len(t, ctx.Data["Issues"], 5)
82
82
}
···
91
91
ctx.Req.Form.Set("state", "closed")
92
92
ctx.Req.Form.Set("sort", "furthestduedate")
93
93
Milestones(ctx)
94
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
94
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
95
95
assert.EqualValues(t, map[int64]int64{1: 1}, ctx.Data["Counts"])
96
96
assert.EqualValues(t, true, ctx.Data["IsShowClosed"])
97
97
assert.EqualValues(t, "furthestduedate", ctx.Data["SortType"])
98
98
assert.EqualValues(t, 1, ctx.Data["Total"])
99
99
assert.Len(t, ctx.Data["Milestones"], 1)
100
100
assert.Len(t, ctx.Data["Repos"], 2) // both repo 42 and 1 have milestones and both are owned by user 2
101
-
assert.EqualValues(t, "user2/glob", ctx.Data["Repos"].(repo_model.RepositoryList)[0].FullName())
102
-
assert.EqualValues(t, "user2/repo1", ctx.Data["Repos"].(repo_model.RepositoryList)[1].FullName())
101
+
assert.Equal(t, "user2/glob", ctx.Data["Repos"].(repo_model.RepositoryList)[0].FullName())
102
+
assert.Equal(t, "user2/repo1", ctx.Data["Repos"].(repo_model.RepositoryList)[1].FullName())
103
103
}
104
104
105
105
func TestMilestonesForSpecificRepo(t *testing.T) {
···
113
113
ctx.Req.Form.Set("state", "closed")
114
114
ctx.Req.Form.Set("sort", "furthestduedate")
115
115
Milestones(ctx)
116
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
116
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
117
117
assert.EqualValues(t, map[int64]int64{1: 1}, ctx.Data["Counts"])
118
118
assert.EqualValues(t, true, ctx.Data["IsShowClosed"])
119
119
assert.EqualValues(t, "furthestduedate", ctx.Data["SortType"])
···
144
144
contexttest.LoadUser(t, ctx, 2)
145
145
contexttest.LoadOrganization(t, ctx, 3)
146
146
Issues(ctx)
147
-
assert.EqualValues(t, http.StatusOK, ctx.Resp.Status())
147
+
assert.Equal(t, http.StatusOK, ctx.Resp.Status())
148
148
149
149
assert.True(t, ctx.Data["PageIsOrgIssues"].(bool))
150
150
···
163
163
164
164
if assert.Len(t, labels, len(orgLabels)) {
165
165
for i, label := range labels {
166
-
assert.EqualValues(t, orgLabels[i].OrgID, label.OrgID)
167
-
assert.EqualValues(t, orgLabels[i].ID, label.ID)
168
-
assert.EqualValues(t, orgLabels[i].Name, label.Name)
166
+
assert.Equal(t, orgLabels[i].OrgID, label.OrgID)
167
+
assert.Equal(t, orgLabels[i].ID, label.ID)
168
+
assert.Equal(t, orgLabels[i].Name, label.Name)
169
169
}
170
170
}
171
171
}
+3
-2
routers/web/user/notification.go
+3
-2
routers/web/user/notification.go
···
340
340
return 0
341
341
}
342
342
reviewTyp := issues_model.ReviewTypeApprove
343
-
if typ == "reject" {
343
+
switch typ {
344
+
case "reject":
344
345
reviewTyp = issues_model.ReviewTypeReject
345
-
} else if typ == "waiting" {
346
+
case "waiting":
346
347
reviewTyp = issues_model.ReviewTypeRequest
347
348
}
348
349
for _, count := range counts {
+4
-4
routers/web/user/setting/account.go
+4
-4
routers/web/user/setting/account.go
···
178
178
// Set Email Notification Preference
179
179
if ctx.FormString("_method") == "NOTIFICATION" {
180
180
preference := ctx.FormString("preference")
181
-
if !(preference == user_model.EmailNotificationsEnabled ||
182
-
preference == user_model.EmailNotificationsOnMention ||
183
-
preference == user_model.EmailNotificationsDisabled ||
184
-
preference == user_model.EmailNotificationsAndYourOwn) {
181
+
if preference != user_model.EmailNotificationsEnabled &&
182
+
preference != user_model.EmailNotificationsOnMention &&
183
+
preference != user_model.EmailNotificationsDisabled &&
184
+
preference != user_model.EmailNotificationsAndYourOwn {
185
185
log.Error("Email notifications preference change returned unrecognized option %s: %s", preference, ctx.Doer.Name)
186
186
ctx.ServerError("SetEmailPreference", errors.New("option unrecognized"))
187
187
return
+1
-1
routers/web/user/setting/account_test.go
+1
-1
routers/web/user/setting/account_test.go
+1
-1
routers/web/user/setting/profile.go
+1
-1
routers/web/user/setting/profile.go
···
146
146
}
147
147
148
148
st := typesniffer.DetectContentType(data)
149
-
if !(st.IsImage() && !st.IsSvgImage()) {
149
+
if !st.IsImage() || st.IsSvgImage() {
150
150
return errors.New(ctx.Locale.TrString("settings.uploaded_avatar_not_a_image"))
151
151
}
152
152
if err = user_service.UploadAvatar(ctx, ctxUser, data); err != nil {
+3
-3
routers/web/web.go
+3
-3
routers/web/web.go
···
812
812
individualPermsChecker := func(ctx *context.Context) {
813
813
// org permissions have been checked in context.OrgAssignment(), but individual permissions haven't been checked.
814
814
if ctx.ContextUser.IsIndividual() {
815
-
switch {
816
-
case ctx.ContextUser.Visibility == structs.VisibleTypePrivate:
815
+
switch ctx.ContextUser.Visibility {
816
+
case structs.VisibleTypePrivate:
817
817
if ctx.Doer == nil || (ctx.ContextUser.ID != ctx.Doer.ID && !ctx.Doer.IsAdmin) {
818
818
ctx.NotFound("Visit Project", nil)
819
819
return
820
820
}
821
-
case ctx.ContextUser.Visibility == structs.VisibleTypeLimited:
821
+
case structs.VisibleTypeLimited:
822
822
if ctx.Doer == nil {
823
823
ctx.NotFound("Visit Project", nil)
824
824
return
+2
-2
services/actions/auth_test.go
+2
-2
services/actions/auth_test.go
···
19
19
var taskID int64 = 23
20
20
token, err := CreateAuthorizationToken(taskID, 1, 2)
21
21
require.NoError(t, err)
22
-
assert.NotEqual(t, "", token)
22
+
assert.NotEmpty(t, token)
23
23
claims := jwt.MapClaims{}
24
24
_, err = jwt.ParseWithClaims(token, claims, func(t *jwt.Token) (any, error) {
25
25
return setting.GetGeneralTokenSigningSecret(), nil
···
45
45
var taskID int64 = 23
46
46
token, err := CreateAuthorizationToken(taskID, 1, 2)
47
47
require.NoError(t, err)
48
-
assert.NotEqual(t, "", token)
48
+
assert.NotEmpty(t, token)
49
49
headers := http.Header{}
50
50
headers.Set("Authorization", "Bearer "+token)
51
51
rTaskID, err := ParseAuthorizationToken(&http.Request{
+1
-1
services/actions/cleanup_test.go
+1
-1
services/actions/cleanup_test.go
···
24
24
require.NoError(t, CleanupLogs(db.DefaultContext))
25
25
26
26
task := unittest.AssertExistsAndLoadBean(t, &actions_model.ActionTask{ID: 1001})
27
-
assert.EqualValues(t, "does-not-exist", task.LogFilename)
27
+
assert.Equal(t, "does-not-exist", task.LogFilename)
28
28
assert.True(t, task.LogExpired)
29
29
assert.Nil(t, task.LogIndexes)
30
30
})
+1
-1
services/attachment/attachment_test.go
+1
-1
services/attachment/attachment_test.go
···
43
43
44
44
attachment, err := repo_model.GetAttachmentByUUID(db.DefaultContext, attach.UUID)
45
45
require.NoError(t, err)
46
-
assert.EqualValues(t, user.ID, attachment.UploaderID)
46
+
assert.Equal(t, user.ID, attachment.UploaderID)
47
47
assert.Equal(t, int64(0), attachment.DownloadCount)
48
48
}
+8
-8
services/auth/reverseproxy_test.go
+8
-8
services/auth/reverseproxy_test.go
···
38
38
39
39
require.EqualValues(t, 1, user_model.CountUsers(db.DefaultContext, nil))
40
40
unittest.AssertExistsAndLoadBean(t, &user_model.User{Email: "edgar@example.org", Name: "Edgar", LowerName: "edgar", FullName: "Edgar Allan Poe", IsAdmin: true})
41
-
require.EqualValues(t, "edgar@example.org", user.Email)
42
-
require.EqualValues(t, "Edgar", user.Name)
43
-
require.EqualValues(t, "edgar", user.LowerName)
44
-
require.EqualValues(t, "Edgar Allan Poe", user.FullName)
41
+
require.Equal(t, "edgar@example.org", user.Email)
42
+
require.Equal(t, "Edgar", user.Name)
43
+
require.Equal(t, "edgar", user.LowerName)
44
+
require.Equal(t, "Edgar Allan Poe", user.FullName)
45
45
require.True(t, user.IsAdmin)
46
46
})
47
47
···
58
58
59
59
require.EqualValues(t, 2, user_model.CountUsers(db.DefaultContext, nil))
60
60
unittest.AssertExistsAndLoadBean(t, &user_model.User{Email: "gusted@example.org", Name: "Gusted", LowerName: "gusted", FullName: "❤‿❤"}, "is_admin = false")
61
-
require.EqualValues(t, "gusted@example.org", user.Email)
62
-
require.EqualValues(t, "Gusted", user.Name)
63
-
require.EqualValues(t, "gusted", user.LowerName)
64
-
require.EqualValues(t, "❤‿❤", user.FullName)
61
+
require.Equal(t, "gusted@example.org", user.Email)
62
+
require.Equal(t, "Gusted", user.Name)
63
+
require.Equal(t, "gusted", user.LowerName)
64
+
require.Equal(t, "❤‿❤", user.FullName)
65
65
require.False(t, user.IsAdmin)
66
66
})
67
67
}
+8
-8
services/auth/source/oauth2/jwtsigningkey_test.go
+8
-8
services/auth/source/oauth2/jwtsigningkey_test.go
···
30
30
31
31
block, _ := pem.Decode(fileContent)
32
32
assert.NotNil(t, block)
33
-
assert.EqualValues(t, "PRIVATE KEY", block.Type)
33
+
assert.Equal(t, "PRIVATE KEY", block.Type)
34
34
35
35
parsedKey, err := x509.ParsePKCS8PrivateKey(block.Bytes)
36
36
require.NoError(t, err)
···
44
44
parsedKey := loadKey(t)
45
45
46
46
rsaPrivateKey := parsedKey.(*rsa.PrivateKey)
47
-
assert.EqualValues(t, 2048, rsaPrivateKey.N.BitLen())
47
+
assert.Equal(t, 2048, rsaPrivateKey.N.BitLen())
48
48
49
49
t.Run("Load key with differ specified algorithm", func(t *testing.T) {
50
50
defer test.MockVariableValue(&setting.OAuth2.JWTSigningAlgorithm, "EdDSA")()
51
51
52
52
parsedKey := loadKey(t)
53
53
rsaPrivateKey := parsedKey.(*rsa.PrivateKey)
54
-
assert.EqualValues(t, 2048, rsaPrivateKey.N.BitLen())
54
+
assert.Equal(t, 2048, rsaPrivateKey.N.BitLen())
55
55
})
56
56
})
57
57
···
62
62
parsedKey := loadKey(t)
63
63
64
64
rsaPrivateKey := parsedKey.(*rsa.PrivateKey)
65
-
assert.EqualValues(t, 3072, rsaPrivateKey.N.BitLen())
65
+
assert.Equal(t, 3072, rsaPrivateKey.N.BitLen())
66
66
})
67
67
68
68
t.Run("RSA-4096", func(t *testing.T) {
···
72
72
parsedKey := loadKey(t)
73
73
74
74
rsaPrivateKey := parsedKey.(*rsa.PrivateKey)
75
-
assert.EqualValues(t, 4096, rsaPrivateKey.N.BitLen())
75
+
assert.Equal(t, 4096, rsaPrivateKey.N.BitLen())
76
76
})
77
77
78
78
t.Run("ECDSA-256", func(t *testing.T) {
···
82
82
parsedKey := loadKey(t)
83
83
84
84
ecdsaPrivateKey := parsedKey.(*ecdsa.PrivateKey)
85
-
assert.EqualValues(t, 256, ecdsaPrivateKey.Params().BitSize)
85
+
assert.Equal(t, 256, ecdsaPrivateKey.Params().BitSize)
86
86
})
87
87
88
88
t.Run("ECDSA-384", func(t *testing.T) {
···
92
92
parsedKey := loadKey(t)
93
93
94
94
ecdsaPrivateKey := parsedKey.(*ecdsa.PrivateKey)
95
-
assert.EqualValues(t, 384, ecdsaPrivateKey.Params().BitSize)
95
+
assert.Equal(t, 384, ecdsaPrivateKey.Params().BitSize)
96
96
})
97
97
98
98
t.Run("ECDSA-512", func(t *testing.T) {
···
102
102
parsedKey := loadKey(t)
103
103
104
104
ecdsaPrivateKey := parsedKey.(*ecdsa.PrivateKey)
105
-
assert.EqualValues(t, 521, ecdsaPrivateKey.Params().BitSize)
105
+
assert.Equal(t, 521, ecdsaPrivateKey.Params().BitSize)
106
106
})
107
107
108
108
t.Run("EdDSA", func(t *testing.T) {
+4
-4
services/context/api.go
+4
-4
services/context/api.go
···
186
186
if status == http.StatusInternalServerError {
187
187
log.ErrorWithSkip(1, "%s: %s", title, message)
188
188
189
-
if setting.IsProd && !(ctx.Doer != nil && ctx.Doer.IsAdmin) {
189
+
if setting.IsProd && (ctx.Doer == nil || !ctx.Doer.IsAdmin) {
190
190
message = ""
191
191
}
192
192
}
···
285
285
}
286
286
defer baseCleanUp()
287
287
288
-
ctx.Base.AppendContextValue(apiContextKey, ctx)
289
-
ctx.Base.AppendContextValueFunc(gitrepo.RepositoryContextKey, func() any { return ctx.Repo.GitRepo })
288
+
ctx.AppendContextValue(apiContextKey, ctx)
289
+
ctx.AppendContextValueFunc(gitrepo.RepositoryContextKey, func() any { return ctx.Repo.GitRepo })
290
290
291
291
// If request sends files, parse them here otherwise the Query() can't be parsed and the CsrfToken will be invalid.
292
292
if ctx.Req.Method == "POST" && strings.Contains(ctx.Req.Header.Get("Content-Type"), "multipart/form-data") {
···
334
334
func ReferencesGitRepo(allowEmpty ...bool) func(ctx *APIContext) (cancel context.CancelFunc) {
335
335
return func(ctx *APIContext) (cancel context.CancelFunc) {
336
336
// Empty repository does not have reference information.
337
-
if ctx.Repo.Repository.IsEmpty && !(len(allowEmpty) != 0 && allowEmpty[0]) {
337
+
if ctx.Repo.Repository.IsEmpty && (len(allowEmpty) == 0 || !allowEmpty[0]) {
338
338
return nil
339
339
}
340
340
+1
-1
services/context/api_test.go
+1
-1
services/context/api_test.go
+3
-3
services/context/context.go
+3
-3
services/context/context.go
···
100
100
101
101
func NewTemplateContextForWeb(ctx *Context) TemplateContext {
102
102
tmplCtx := NewTemplateContext(ctx)
103
-
tmplCtx["Locale"] = ctx.Base.Locale
103
+
tmplCtx["Locale"] = ctx.Locale
104
104
tmplCtx["AvatarUtils"] = templates.NewAvatarUtils(ctx)
105
105
return tmplCtx
106
106
}
···
151
151
ctx.PageData = map[string]any{}
152
152
ctx.Data["PageData"] = ctx.PageData
153
153
154
-
ctx.Base.AppendContextValue(WebContextKey, ctx)
155
-
ctx.Base.AppendContextValueFunc(gitrepo.RepositoryContextKey, func() any { return ctx.Repo.GitRepo })
154
+
ctx.AppendContextValue(WebContextKey, ctx)
155
+
ctx.AppendContextValueFunc(gitrepo.RepositoryContextKey, func() any { return ctx.Repo.GitRepo })
156
156
157
157
ctx.Csrf = NewCSRFProtector(csrfOpts)
158
158
+1
-1
services/context/package.go
+1
-1
services/context/package.go
···
158
158
159
159
// it is still needed when rendering 500 page in a package handler
160
160
ctx := NewWebContext(base, renderer, nil)
161
-
ctx.Base.AppendContextValue(WebContextKey, ctx)
161
+
ctx.AppendContextValue(WebContextKey, ctx)
162
162
next.ServeHTTP(ctx.Resp, ctx.Req)
163
163
})
164
164
}
+1
-1
services/context/private.go
+1
-1
services/context/private.go
+2
-2
services/context/quota.go
+2
-2
services/context/quota.go
···
64
64
65
65
// ctx.CheckQuota checks whether the user in question is within quota limits (web context)
66
66
func (ctx *Context) CheckQuota(subject quota_model.LimitSubject, userID int64, username string) bool {
67
-
ok, err := checkQuota(ctx.Base.originCtx, subject, userID, username, func(userID int64, username string) {
67
+
ok, err := checkQuota(ctx.originCtx, subject, userID, username, func(userID int64, username string) {
68
68
showHTML := false
69
69
for _, part := range ctx.Req.Header["Accept"] {
70
70
if strings.Contains(part, "text/html") {
···
91
91
92
92
// ctx.CheckQuota checks whether the user in question is within quota limits (API context)
93
93
func (ctx *APIContext) CheckQuota(subject quota_model.LimitSubject, userID int64, username string) bool {
94
-
ok, err := checkQuota(ctx.Base.originCtx, subject, userID, username, func(userID int64, username string) {
94
+
ok, err := checkQuota(ctx.originCtx, subject, userID, username, func(userID int64, username string) {
95
95
ctx.JSON(http.StatusRequestEntityTooLarge, APIQuotaExceeded{
96
96
Message: "quota exceeded",
97
97
UserID: userID,
+4
-4
services/context/repo.go
+4
-4
services/context/repo.go
···
83
83
84
84
// CanCreateBranch returns true if repository is editable and user has proper access level.
85
85
func (r *Repository) CanCreateBranch() bool {
86
-
return r.Permission.CanWrite(unit_model.TypeCode) && r.Repository.CanCreateBranch()
86
+
return r.CanWrite(unit_model.TypeCode) && r.Repository.CanCreateBranch()
87
87
}
88
88
89
89
func (r *Repository) GetObjectFormat() git.ObjectFormat {
···
160
160
// 2. Is the user a contributor, admin, poster or assignee and do the repository policies require this?
161
161
isAssigned, _ := issues_model.IsUserAssignedToIssue(ctx, issue, user)
162
162
return r.Repository.IsTimetrackerEnabled(ctx) && (!r.Repository.AllowOnlyContributorsToTrackTime(ctx) ||
163
-
r.Permission.CanWriteIssuesOrPulls(issue.IsPull) || issue.IsPoster(user.ID) || isAssigned)
163
+
r.CanWriteIssuesOrPulls(issue.IsPull) || issue.IsPoster(user.ID) || isAssigned)
164
164
}
165
165
166
166
// CanCreateIssueDependencies returns whether or not a user can create dependencies.
167
167
func (r *Repository) CanCreateIssueDependencies(ctx context.Context, user *user_model.User, isPull bool) bool {
168
-
return r.Repository.IsDependenciesEnabled(ctx) && r.Permission.CanWriteIssuesOrPulls(isPull)
168
+
return r.Repository.IsDependenciesEnabled(ctx) && r.CanWriteIssuesOrPulls(isPull)
169
169
}
170
170
171
171
// GetCommitsCount returns cached commit count for current view
···
378
378
}
379
379
380
380
// Check access.
381
-
if !ctx.Repo.Permission.HasAccess() {
381
+
if !ctx.Repo.HasAccess() {
382
382
if ctx.FormString("go-get") == "1" {
383
383
EarlyResponseForGoGetMeta(ctx)
384
384
return
+4
-3
services/context/upload/upload.go
+4
-3
services/context/upload/upload.go
···
76
76
77
77
// AddUploadContext renders template values for dropzone
78
78
func AddUploadContext(ctx *context.Context, uploadType string) {
79
-
if uploadType == "release" {
79
+
switch uploadType {
80
+
case "release":
80
81
ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/releases/attachments"
81
82
ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/releases/attachments/remove"
82
83
ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/releases/attachments"
83
84
ctx.Data["UploadAccepts"] = strings.ReplaceAll(setting.Repository.Release.AllowedTypes, "|", ",")
84
85
ctx.Data["UploadMaxFiles"] = setting.Attachment.MaxFiles
85
86
ctx.Data["UploadMaxSize"] = setting.Attachment.MaxSize
86
-
} else if uploadType == "comment" {
87
+
case "comment":
87
88
ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/issues/attachments"
88
89
ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/issues/attachments/remove"
89
90
if len(ctx.Params(":index")) > 0 {
···
94
95
ctx.Data["UploadAccepts"] = strings.ReplaceAll(setting.Attachment.AllowedTypes, "|", ",")
95
96
ctx.Data["UploadMaxFiles"] = setting.Attachment.MaxFiles
96
97
ctx.Data["UploadMaxSize"] = setting.Attachment.MaxSize
97
-
} else if uploadType == "repo" {
98
+
case "repo":
98
99
ctx.Data["UploadUrl"] = ctx.Repo.RepoLink + "/upload-file"
99
100
ctx.Data["UploadRemoveUrl"] = ctx.Repo.RepoLink + "/upload-remove"
100
101
ctx.Data["UploadLinkUrl"] = ctx.Repo.RepoLink + "/upload-file"
+3
-3
services/contexttest/context_tests.go
+3
-3
services/contexttest/context_tests.go
···
68
68
ctx.PageData = map[string]any{}
69
69
ctx.Data["PageStartTime"] = time.Now()
70
70
chiCtx := chi.NewRouteContext()
71
-
ctx.Base.AppendContextValue(chi.RouteCtxKey, chiCtx)
71
+
ctx.AppendContextValue(chi.RouteCtxKey, chiCtx)
72
72
return ctx, resp
73
73
}
74
74
···
83
83
_ = baseCleanUp // during test, it doesn't need to do clean up. TODO: this can be improved later
84
84
85
85
chiCtx := chi.NewRouteContext()
86
-
ctx.Base.AppendContextValue(chi.RouteCtxKey, chiCtx)
86
+
ctx.AppendContextValue(chi.RouteCtxKey, chiCtx)
87
87
return ctx, resp
88
88
}
89
89
···
96
96
ctx := &context.PrivateContext{Base: base}
97
97
_ = baseCleanUp // during test, it doesn't need to do clean up. TODO: this can be improved later
98
98
chiCtx := chi.NewRouteContext()
99
-
ctx.Base.AppendContextValue(chi.RouteCtxKey, chiCtx)
99
+
ctx.AppendContextValue(chi.RouteCtxKey, chiCtx)
100
100
return ctx, resp
101
101
}
102
102
+1
-1
services/convert/git_commit_test.go
+1
-1
services/convert/git_commit_test.go
···
34
34
commitMeta := ToCommitMeta(headRepo, tag)
35
35
36
36
assert.NotNil(t, commitMeta)
37
-
assert.EqualValues(t, &api.CommitMeta{
37
+
assert.Equal(t, &api.CommitMeta{
38
38
SHA: sha1.EmptyObjectID().String(),
39
39
URL: util.URLJoin(headRepo.APIURL(), "git/commits", sha1.EmptyObjectID().String()),
40
40
Created: time.Unix(0, 0),
+1
-1
services/convert/notification.go
+1
-1
services/convert/notification.go
···
17
17
func ToNotificationThread(ctx context.Context, n *activities_model.Notification) *api.NotificationThread {
18
18
result := &api.NotificationThread{
19
19
ID: n.ID,
20
-
Unread: !(n.Status == activities_model.NotificationStatusRead || n.Status == activities_model.NotificationStatusPinned),
20
+
Unread: n.Status != activities_model.NotificationStatusRead && n.Status != activities_model.NotificationStatusPinned,
21
21
Pinned: n.Status == activities_model.NotificationStatusPinned,
22
22
UpdatedAt: n.UpdatedUnix.AsTime(),
23
23
URL: n.APIURL(),
+1
-1
services/convert/pull_review.go
+1
-1
services/convert/pull_review.go
···
66
66
result := make([]*api.PullReview, 0, len(rl))
67
67
for i := range rl {
68
68
// show pending reviews only for the user who created them
69
-
if rl[i].Type == issues_model.ReviewTypePending && (doer == nil || !(doer.IsAdmin || doer.ID == rl[i].ReviewerID)) {
69
+
if rl[i].Type == issues_model.ReviewTypePending && (doer == nil || (!doer.IsAdmin && doer.ID != rl[i].ReviewerID)) {
70
70
continue
71
71
}
72
72
r, err := ToPullReview(ctx, rl[i], doer)
+1
-1
services/convert/pull_test.go
+1
-1
services/convert/pull_test.go
···
29
29
require.NoError(t, pr.LoadIssue(db.DefaultContext))
30
30
apiPullRequest := ToAPIPullRequest(git.DefaultContext, pr, nil)
31
31
assert.NotNil(t, apiPullRequest)
32
-
assert.EqualValues(t, &structs.PRBranchInfo{
32
+
assert.Equal(t, &structs.PRBranchInfo{
33
33
Name: "branch1",
34
34
Ref: "refs/pull/2/head",
35
35
Sha: "4a357436d925b5c974181ff12a994538ddc5a269",
+2
-2
services/convert/release_test.go
+2
-2
services/convert/release_test.go
···
24
24
apiRelease := ToAPIRelease(db.DefaultContext, repo1, release1)
25
25
assert.NotNil(t, apiRelease)
26
26
assert.EqualValues(t, 1, apiRelease.ID)
27
-
assert.EqualValues(t, "https://try.gitea.io/api/v1/repos/user2/repo1/releases/1", apiRelease.URL)
28
-
assert.EqualValues(t, "https://try.gitea.io/api/v1/repos/user2/repo1/releases/1/assets", apiRelease.UploadURL)
27
+
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/releases/1", apiRelease.URL)
28
+
assert.Equal(t, "https://try.gitea.io/api/v1/repos/user2/repo1/releases/1/assets", apiRelease.UploadURL)
29
29
}
+2
-2
services/convert/user_test.go
+2
-2
services/convert/user_test.go
···
31
31
32
32
apiUser = toUser(db.DefaultContext, user1, false, false)
33
33
assert.False(t, apiUser.IsAdmin)
34
-
assert.EqualValues(t, api.VisibleTypePublic.String(), apiUser.Visibility)
34
+
assert.Equal(t, api.VisibleTypePublic.String(), apiUser.Visibility)
35
35
36
36
user31 := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 31, IsAdmin: false, Visibility: api.VisibleTypePrivate})
37
37
38
38
apiUser = toUser(db.DefaultContext, user31, true, true)
39
39
assert.False(t, apiUser.IsAdmin)
40
-
assert.EqualValues(t, api.VisibleTypePrivate.String(), apiUser.Visibility)
40
+
assert.Equal(t, api.VisibleTypePrivate.String(), apiUser.Visibility)
41
41
}
+4
-4
services/convert/utils_test.go
+4
-4
services/convert/utils_test.go
···
10
10
)
11
11
12
12
func TestToCorrectPageSize(t *testing.T) {
13
-
assert.EqualValues(t, 30, ToCorrectPageSize(0))
14
-
assert.EqualValues(t, 30, ToCorrectPageSize(-10))
15
-
assert.EqualValues(t, 20, ToCorrectPageSize(20))
16
-
assert.EqualValues(t, 50, ToCorrectPageSize(100))
13
+
assert.Equal(t, 30, ToCorrectPageSize(0))
14
+
assert.Equal(t, 30, ToCorrectPageSize(-10))
15
+
assert.Equal(t, 20, ToCorrectPageSize(20))
16
+
assert.Equal(t, 50, ToCorrectPageSize(100))
17
17
}
18
18
19
19
func TestToGitServiceType(t *testing.T) {
+2
-2
services/doctor/fix16961_test.go
+2
-2
services/doctor/fix16961_test.go
···
221
221
if gotFixed != tt.wantFixed {
222
222
t.Errorf("fixPullRequestsConfig_16961() = %v, want %v", gotFixed, tt.wantFixed)
223
223
}
224
-
assert.EqualValues(t, &tt.expected, cfg)
224
+
assert.Equal(t, &tt.expected, cfg)
225
225
})
226
226
}
227
227
}
···
265
265
if gotFixed != tt.wantFixed {
266
266
t.Errorf("fixIssuesConfig_16961() = %v, want %v", gotFixed, tt.wantFixed)
267
267
}
268
-
assert.EqualValues(t, &tt.expected, cfg)
268
+
assert.Equal(t, &tt.expected, cfg)
269
269
})
270
270
}
271
271
}
+1
-1
services/f3/util/logger_test.go
+1
-1
services/f3/util/logger_test.go
+1
-1
services/gitdiff/gitdiff.go
+1
-1
services/gitdiff/gitdiff.go
···
1060
1060
_, _ = fmt.Fscanf(rd, "%s ", &name)
1061
1061
char, _ := rd.ReadByte()
1062
1062
_ = rd.UnreadByte()
1063
-
for !(char == 0 || char == '"' || char == 'b') {
1063
+
for char != 0 && char != '"' && char != 'b' {
1064
1064
var suffix string
1065
1065
_, _ = fmt.Fscanf(rd, "%s ", &suffix)
1066
1066
name += " " + suffix
+3
-2
services/gitdiff/highlightdiff.go
+3
-2
services/gitdiff/highlightdiff.go
···
14
14
// token is a html tag or entity, eg: "<span ...>", "</span>", "<"
15
15
func extractHTMLToken(s string) (before, token, after string, valid bool) {
16
16
for pos1 := 0; pos1 < len(s); pos1++ {
17
-
if s[pos1] == '<' {
17
+
switch s[pos1] {
18
+
case '<':
18
19
pos2 := strings.IndexByte(s[pos1:], '>')
19
20
if pos2 == -1 {
20
21
return "", "", s, false
21
22
}
22
23
return s[:pos1], s[pos1 : pos1+pos2+1], s[pos1+pos2+1:], true
23
-
} else if s[pos1] == '&' {
24
+
case '&':
24
25
pos2 := strings.IndexByte(s[pos1:], ';')
25
26
if pos2 == -1 {
26
27
return "", "", s, false
+3
-3
services/gitdiff/highlightdiff_test.go
+3
-3
services/gitdiff/highlightdiff_test.go
···
43
43
44
44
diff.Text = "C"
45
45
hcd.recoverOneDiff(&diff)
46
-
assert.Equal(t, "", diff.Text)
46
+
assert.Empty(t, diff.Text)
47
47
}
48
48
49
49
func TestDiffWithHighlightPlaceholder(t *testing.T) {
···
53
53
"a='\U00100000'",
54
54
"a='\U0010FFFD''",
55
55
)
56
-
assert.Equal(t, "", hcd.PlaceholderTokenMap[0x00100000])
57
-
assert.Equal(t, "", hcd.PlaceholderTokenMap[0x0010FFFD])
56
+
assert.Empty(t, hcd.PlaceholderTokenMap[0x00100000])
57
+
assert.Empty(t, hcd.PlaceholderTokenMap[0x0010FFFD])
58
58
59
59
expected := fmt.Sprintf(`<span class="nx">a</span><span class="o">=</span><span class="s1">'</span><span class="removed-code">%s</span>'`, "\U00100000")
60
60
output := diffToHTML(hcd.lineWrapperTags, diffs, DiffLineDel)
+12
-12
services/issue/comments_test.go
+12
-12
services/issue/comments_test.go
···
48
48
// Reactions don't exist anymore for this comment.
49
49
unittest.AssertNotExistsBean(t, &issues_model.Reaction{CommentID: comment.ID})
50
50
// Number of comments was decreased.
51
-
assert.EqualValues(t, issue.NumComments-1, unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: comment.IssueID}).NumComments)
51
+
assert.Equal(t, issue.NumComments-1, unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: comment.IssueID}).NumComments)
52
52
// A notification was fired for the deletion of this comment.
53
-
assert.EqualValues(t, hookTaskCount+1, unittest.GetCount(t, &webhook_model.HookTask{}))
53
+
assert.Equal(t, hookTaskCount+1, unittest.GetCount(t, &webhook_model.HookTask{}))
54
54
})
55
55
56
56
t.Run("Comment of pending review", func(t *testing.T) {
···
59
59
// We have to ensure that this comment's linked review is pending.
60
60
comment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 4}, "review_id != 0")
61
61
review := unittest.AssertExistsAndLoadBean(t, &issues_model.Review{ID: comment.ReviewID})
62
-
assert.EqualValues(t, issues_model.ReviewTypePending, review.Type)
62
+
assert.Equal(t, issues_model.ReviewTypePending, review.Type)
63
63
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: comment.IssueID})
64
64
65
65
require.NoError(t, webhook_model.CreateWebhook(db.DefaultContext, &webhook_model.Webhook{
···
74
74
// The comment doesn't exist anymore.
75
75
unittest.AssertNotExistsBean(t, &issues_model.Comment{ID: comment.ID})
76
76
// Ensure that the number of comments wasn't decreased.
77
-
assert.EqualValues(t, issue.NumComments, unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: comment.IssueID}).NumComments)
77
+
assert.Equal(t, issue.NumComments, unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: comment.IssueID}).NumComments)
78
78
// No notification was fired for the deletion of this comment.
79
-
assert.EqualValues(t, hookTaskCount, unittest.GetCount(t, &webhook_model.HookTask{}))
79
+
assert.Equal(t, hookTaskCount, unittest.GetCount(t, &webhook_model.HookTask{}))
80
80
})
81
81
}
82
82
···
105
105
106
106
newComment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 2})
107
107
// Content was updated.
108
-
assert.EqualValues(t, comment.Content, newComment.Content)
108
+
assert.Equal(t, comment.Content, newComment.Content)
109
109
// Content version was updated.
110
-
assert.EqualValues(t, 2, newComment.ContentVersion)
110
+
assert.Equal(t, 2, newComment.ContentVersion)
111
111
// A notification was fired for the update of this comment.
112
-
assert.EqualValues(t, hookTaskCount+1, unittest.GetCount(t, &webhook_model.HookTask{}))
112
+
assert.Equal(t, hookTaskCount+1, unittest.GetCount(t, &webhook_model.HookTask{}))
113
113
// Issue history was saved for this comment.
114
114
unittest.AssertExistsAndLoadBean(t, &issues_model.ContentHistory{CommentID: comment.ID, IsFirstCreated: true, ContentText: oldContent})
115
115
unittest.AssertExistsAndLoadBean(t, &issues_model.ContentHistory{CommentID: comment.ID, ContentText: comment.Content}, "is_first_created = false")
···
120
120
121
121
comment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 4}, "review_id != 0")
122
122
review := unittest.AssertExistsAndLoadBean(t, &issues_model.Review{ID: comment.ReviewID})
123
-
assert.EqualValues(t, issues_model.ReviewTypePending, review.Type)
123
+
assert.Equal(t, issues_model.ReviewTypePending, review.Type)
124
124
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: comment.IssueID})
125
125
unittest.AssertNotExistsBean(t, &issues_model.ContentHistory{CommentID: comment.ID})
126
126
require.NoError(t, webhook_model.CreateWebhook(db.DefaultContext, &webhook_model.Webhook{
···
136
136
137
137
newComment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 2})
138
138
// Content was updated.
139
-
assert.EqualValues(t, comment.Content, newComment.Content)
139
+
assert.Equal(t, comment.Content, newComment.Content)
140
140
// Content version was updated.
141
-
assert.EqualValues(t, 2, newComment.ContentVersion)
141
+
assert.Equal(t, 2, newComment.ContentVersion)
142
142
// No notification was fired for the update of this comment.
143
-
assert.EqualValues(t, hookTaskCount, unittest.GetCount(t, &webhook_model.HookTask{}))
143
+
assert.Equal(t, hookTaskCount, unittest.GetCount(t, &webhook_model.HookTask{}))
144
144
// Issue history was not saved for this comment.
145
145
unittest.AssertNotExistsBean(t, &issues_model.ContentHistory{CommentID: comment.ID})
146
146
})
+2
-2
services/issue/issue_test.go
+2
-2
services/issue/issue_test.go
···
25
25
repoLink := "/foo/bar"
26
26
27
27
endNames, urls := GetRefEndNamesAndURLs(issues, repoLink)
28
-
assert.EqualValues(t, map[int64]string{1: "branch1", 2: "tag1", 3: "c0ffee"}, endNames)
29
-
assert.EqualValues(t, map[int64]string{
28
+
assert.Equal(t, map[int64]string{1: "branch1", 2: "tag1", 3: "c0ffee"}, endNames)
29
+
assert.Equal(t, map[int64]string{
30
30
1: repoLink + "/src/branch/branch1",
31
31
2: repoLink + "/src/tag/tag1",
32
32
3: repoLink + "/src/commit/c0ffee",
+4
-3
services/lfs/server.go
+4
-3
services/lfs/server.go
···
163
163
}
164
164
165
165
var isUpload bool
166
-
if br.Operation == "upload" {
166
+
switch br.Operation {
167
+
case "upload":
167
168
isUpload = true
168
-
} else if br.Operation == "download" {
169
+
case "download":
169
170
isUpload = false
170
-
} else {
171
+
default:
171
172
log.Trace("Attempt to BATCH with invalid operation: %s", br.Operation)
172
173
writeStatus(ctx, http.StatusBadRequest)
173
174
return
+3
-4
services/mailer/mail_issue.go
+3
-4
services/mailer/mail_issue.go
···
85
85
86
86
// =========== Repo watchers ===========
87
87
// Make repo watchers last, since it's likely the list with the most users
88
-
if !(ctx.Issue.IsPull && ctx.Issue.PullRequest.IsWorkInProgress(ctx) && ctx.ActionType != activities_model.ActionCreatePullRequest) {
88
+
if !ctx.Issue.IsPull || !ctx.Issue.PullRequest.IsWorkInProgress(ctx) || ctx.ActionType == activities_model.ActionCreatePullRequest {
89
89
ids, err = repo_model.GetRepoWatchersIDs(ctx, ctx.Issue.RepoID)
90
90
if err != nil {
91
91
return fmt.Errorf("GetRepoWatchersIDs(%d): %w", ctx.Issue.RepoID, err)
···
137
137
}
138
138
// At this point we exclude:
139
139
// user that don't have all mails enabled or users only get mail on mention and this is one ...
140
-
if !(user.EmailNotificationsPreference == user_model.EmailNotificationsEnabled ||
141
-
user.EmailNotificationsPreference == user_model.EmailNotificationsAndYourOwn ||
142
-
fromMention && user.EmailNotificationsPreference == user_model.EmailNotificationsOnMention) {
140
+
if user.EmailNotificationsPreference != user_model.EmailNotificationsEnabled &&
141
+
user.EmailNotificationsPreference != user_model.EmailNotificationsAndYourOwn && (!fromMention || user.EmailNotificationsPreference != user_model.EmailNotificationsOnMention) {
143
142
continue
144
143
}
145
144
+2
-2
services/mailer/mail_test.go
+2
-2
services/mailer/mail_test.go
···
518
518
t.Run(tc.userDisplayName, func(t *testing.T) {
519
519
user := &user_model.User{FullName: tc.userDisplayName, Name: "tmp"}
520
520
got := fromDisplayName(user)
521
-
assert.EqualValues(t, tc.fromDisplayName, got)
521
+
assert.Equal(t, tc.fromDisplayName, got)
522
522
})
523
523
}
524
524
···
535
535
setting.Domain = oldDomain
536
536
}()
537
537
538
-
assert.EqualValues(t, "Mister X (by Code IT on [code.it])", fromDisplayName(&user_model.User{FullName: "Mister X", Name: "tmp"}))
538
+
assert.Equal(t, "Mister X (by Code IT on [code.it])", fromDisplayName(&user_model.User{FullName: "Mister X", Name: "tmp"}))
539
539
})
540
540
}
541
541
+2
-2
services/mailer/mailer_test.go
+2
-2
services/mailer/mailer_test.go
···
72
72
_, err := m1.ToMessage().WriteTo(buf)
73
73
require.NoError(t, err)
74
74
header, _ := extractMailHeaderAndContent(t, buf.String())
75
-
assert.EqualValues(t, map[string]string{
75
+
assert.Equal(t, map[string]string{
76
76
"Content-Type": "multipart/alternative;",
77
77
"Date": "Mon, 01 Jan 0001 00:00:00 +0000",
78
78
"From": "\"Test Gitea\" <test@gitea.com>",
···
92
92
_, err = m1.ToMessage().WriteTo(buf)
93
93
require.NoError(t, err)
94
94
header, _ = extractMailHeaderAndContent(t, buf.String())
95
-
assert.EqualValues(t, map[string]string{
95
+
assert.Equal(t, map[string]string{
96
96
"Content-Type": "multipart/alternative;",
97
97
"Date": "Mon, 01 Jan 0001 00:00:00 +0000",
98
98
"From": "\"Test Gitea\" <test@gitea.com>",
+10
-8
services/mailer/notify.go
+10
-8
services/mailer/notify.go
···
30
30
issue *issues_model.Issue, comment *issues_model.Comment, mentions []*user_model.User,
31
31
) {
32
32
var act activities_model.ActionType
33
-
if comment.Type == issues_model.CommentTypeClose {
33
+
switch comment.Type {
34
+
case issues_model.CommentTypeClose:
34
35
act = activities_model.ActionCloseIssue
35
-
} else if comment.Type == issues_model.CommentTypeReopen {
36
+
case issues_model.CommentTypeReopen:
36
37
act = activities_model.ActionReopenIssue
37
-
} else if comment.Type == issues_model.CommentTypeComment {
38
+
case issues_model.CommentTypeComment:
38
39
act = activities_model.ActionCommentIssue
39
-
} else if comment.Type == issues_model.CommentTypeCode {
40
+
case issues_model.CommentTypeCode:
40
41
act = activities_model.ActionCommentIssue
41
-
} else if comment.Type == issues_model.CommentTypePullRequestPush {
42
+
case issues_model.CommentTypePullRequestPush:
42
43
act = 0
43
44
}
44
45
···
94
95
95
96
func (m *mailNotifier) PullRequestReview(ctx context.Context, pr *issues_model.PullRequest, r *issues_model.Review, comment *issues_model.Comment, mentions []*user_model.User) {
96
97
var act activities_model.ActionType
97
-
if comment.Type == issues_model.CommentTypeClose {
98
+
switch comment.Type {
99
+
case issues_model.CommentTypeClose:
98
100
act = activities_model.ActionCloseIssue
99
-
} else if comment.Type == issues_model.CommentTypeReopen {
101
+
case issues_model.CommentTypeReopen:
100
102
act = activities_model.ActionReopenIssue
101
-
} else if comment.Type == issues_model.CommentTypeComment {
103
+
case issues_model.CommentTypeComment:
102
104
act = activities_model.ActionCommentPull
103
105
}
104
106
if err := MailParticipantsComment(ctx, comment, act, pr.Issue, mentions); err != nil {
+2
-2
services/migrations/gitea_downloader_test.go
+2
-2
services/migrations/gitea_downloader_test.go
···
45
45
topics, err := downloader.GetTopics()
46
46
require.NoError(t, err)
47
47
sort.Strings(topics)
48
-
assert.EqualValues(t, []string{"ci", "gitea", "migration", "test"}, topics)
48
+
assert.Equal(t, []string{"ci", "gitea", "migration", "test"}, topics)
49
49
50
50
labels, err := downloader.GetLabels()
51
51
require.NoError(t, err)
···
132
132
require.NoError(t, err)
133
133
assert.True(t, isEnd)
134
134
assert.Len(t, issues, 7)
135
-
assert.EqualValues(t, "open", issues[0].State)
135
+
assert.Equal(t, "open", issues[0].State)
136
136
137
137
issues, isEnd, err = downloader.GetIssues(3, 2)
138
138
require.NoError(t, err)
+5
-5
services/migrations/gitea_uploader_test.go
+5
-5
services/migrations/gitea_uploader_test.go
···
64
64
65
65
repo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerID: user.ID, Name: repoName})
66
66
assert.True(t, repo.HasWiki())
67
-
assert.EqualValues(t, repo_model.RepositoryReady, repo.Status)
67
+
assert.Equal(t, repo_model.RepositoryReady, repo.Status)
68
68
69
69
milestones, err := db.Find[issues_model.Milestone](db.DefaultContext, issues_model.FindMilestoneOptions{
70
70
RepoID: repo.ID,
···
173
173
uploader.userMap = make(map[int64]int64)
174
174
err = uploader.remapUser(&source, &target)
175
175
require.NoError(t, err)
176
-
assert.EqualValues(t, user.ID, target.GetUserID())
176
+
assert.Equal(t, user.ID, target.GetUserID())
177
177
}
178
178
179
179
func TestGiteaUploadRemapExternalUser(t *testing.T) {
···
224
224
target = repo_model.Release{}
225
225
err = uploader.remapUser(&source, &target)
226
226
require.NoError(t, err)
227
-
assert.EqualValues(t, linkedUser.ID, target.GetUserID())
227
+
assert.Equal(t, linkedUser.ID, target.GetUserID())
228
228
}
229
229
230
230
func TestGiteaUploadUpdateGitForPullRequest(t *testing.T) {
···
504
504
505
505
head, err := uploader.updateGitForPullRequest(&testCase.pr)
506
506
require.NoError(t, err)
507
-
assert.EqualValues(t, testCase.head, head)
507
+
assert.Equal(t, testCase.head, head)
508
508
509
509
log.Info(stopMark)
510
510
511
511
logFiltered, logStopped := logChecker.Check(5 * time.Second)
512
512
assert.True(t, logStopped)
513
513
if len(testCase.logFilter) > 0 {
514
-
assert.EqualValues(t, testCase.logFiltered, logFiltered, "for log message filters: %v", testCase.logFilter)
514
+
assert.Equal(t, testCase.logFiltered, logFiltered, "for log message filters: %v", testCase.logFilter)
515
515
}
516
516
})
517
517
}
+5
-5
services/migrations/gitlab_test.go
+5
-5
services/migrations/gitlab_test.go
···
49
49
topics, err := downloader.GetTopics()
50
50
require.NoError(t, err)
51
51
assert.Len(t, topics, 2)
52
-
assert.EqualValues(t, []string{"migration", "test"}, topics)
52
+
assert.Equal(t, []string{"migration", "test"}, topics)
53
53
54
54
milestones, err := downloader.GetMilestones()
55
55
require.NoError(t, err)
···
352
352
// the only issue in this repository has number 2
353
353
assert.Len(t, issues, 1)
354
354
assert.EqualValues(t, 2, issues[0].Number)
355
-
assert.EqualValues(t, "vpn unlimited errors", issues[0].Title)
355
+
assert.Equal(t, "vpn unlimited errors", issues[0].Title)
356
356
357
357
prs, _, err := downloader.GetPullRequests(1, 10)
358
358
require.NoError(t, err)
···
361
361
// pull request 3 in Forgejo
362
362
assert.Len(t, prs, 1)
363
363
assert.EqualValues(t, 3, prs[0].Number)
364
-
assert.EqualValues(t, "Review", prs[0].Title)
364
+
assert.Equal(t, "Review", prs[0].Title)
365
365
}
366
366
367
367
func gitlabClientMockSetup(t *testing.T) (*http.ServeMux, *httptest.Server, *gitlab.Client) {
···
531
531
require.NoError(t, json.Unmarshal([]byte(testResponse), &awards))
532
532
533
533
reactions := downloader.awardsToReactions(awards)
534
-
assert.EqualValues(t, []*base.Reaction{
534
+
assert.Equal(t, []*base.Reaction{
535
535
{
536
536
UserName: "lafriks",
537
537
UserID: 1241334,
···
623
623
624
624
for i, note := range notes {
625
625
actualComment := *downloader.convertNoteToComment(17, ¬e)
626
-
assert.EqualValues(t, actualComment, comments[i])
626
+
assert.Equal(t, actualComment, comments[i])
627
627
}
628
628
}
629
629
+3
-3
services/migrations/gogs_test.go
+3
-3
services/migrations/gogs_test.go
···
215
215
}
216
216
217
217
assert.IsType(t, &GogsDownloader{}, got)
218
-
assert.EqualValues(t, tt.baseURL, got.(*GogsDownloader).baseURL)
219
-
assert.EqualValues(t, tt.repoOwner, got.(*GogsDownloader).repoOwner)
220
-
assert.EqualValues(t, tt.repoName, got.(*GogsDownloader).repoName)
218
+
assert.Equal(t, tt.baseURL, got.(*GogsDownloader).baseURL)
219
+
assert.Equal(t, tt.repoOwner, got.(*GogsDownloader).repoOwner)
220
+
assert.Equal(t, tt.repoName, got.(*GogsDownloader).repoName)
221
221
})
222
222
}
223
223
}
+30
-30
services/mirror/mirror_test.go
+30
-30
services/mirror/mirror_test.go
···
24
24
`
25
25
results := parseRemoteUpdateOutput(output, "origin")
26
26
assert.Len(t, results, 10)
27
-
assert.EqualValues(t, "refs/tags/v0.1.8", results[0].refName.String())
28
-
assert.EqualValues(t, gitShortEmptySha, results[0].oldCommitID)
29
-
assert.EqualValues(t, "", results[0].newCommitID)
27
+
assert.Equal(t, "refs/tags/v0.1.8", results[0].refName.String())
28
+
assert.Equal(t, gitShortEmptySha, results[0].oldCommitID)
29
+
assert.Empty(t, results[0].newCommitID)
30
30
31
-
assert.EqualValues(t, "refs/heads/master", results[1].refName.String())
32
-
assert.EqualValues(t, gitShortEmptySha, results[1].oldCommitID)
33
-
assert.EqualValues(t, "", results[1].newCommitID)
31
+
assert.Equal(t, "refs/heads/master", results[1].refName.String())
32
+
assert.Equal(t, gitShortEmptySha, results[1].oldCommitID)
33
+
assert.Empty(t, results[1].newCommitID)
34
34
35
-
assert.EqualValues(t, "refs/heads/test1", results[2].refName.String())
36
-
assert.EqualValues(t, "", results[2].oldCommitID)
37
-
assert.EqualValues(t, gitShortEmptySha, results[2].newCommitID)
35
+
assert.Equal(t, "refs/heads/test1", results[2].refName.String())
36
+
assert.Empty(t, results[2].oldCommitID)
37
+
assert.Equal(t, gitShortEmptySha, results[2].newCommitID)
38
38
39
-
assert.EqualValues(t, "refs/tags/tag1", results[3].refName.String())
40
-
assert.EqualValues(t, "", results[3].oldCommitID)
41
-
assert.EqualValues(t, gitShortEmptySha, results[3].newCommitID)
39
+
assert.Equal(t, "refs/tags/tag1", results[3].refName.String())
40
+
assert.Empty(t, results[3].oldCommitID)
41
+
assert.Equal(t, gitShortEmptySha, results[3].newCommitID)
42
42
43
-
assert.EqualValues(t, "refs/heads/test2", results[4].refName.String())
44
-
assert.EqualValues(t, "f895a1e", results[4].oldCommitID)
45
-
assert.EqualValues(t, "957a993", results[4].newCommitID)
43
+
assert.Equal(t, "refs/heads/test2", results[4].refName.String())
44
+
assert.Equal(t, "f895a1e", results[4].oldCommitID)
45
+
assert.Equal(t, "957a993", results[4].newCommitID)
46
46
47
-
assert.EqualValues(t, "refs/heads/test3", results[5].refName.String())
48
-
assert.EqualValues(t, "957a993", results[5].oldCommitID)
49
-
assert.EqualValues(t, "a87ba5f", results[5].newCommitID)
47
+
assert.Equal(t, "refs/heads/test3", results[5].refName.String())
48
+
assert.Equal(t, "957a993", results[5].oldCommitID)
49
+
assert.Equal(t, "a87ba5f", results[5].newCommitID)
50
50
51
-
assert.EqualValues(t, "refs/pull/26595/head", results[6].refName.String())
52
-
assert.EqualValues(t, gitShortEmptySha, results[6].oldCommitID)
53
-
assert.EqualValues(t, "", results[6].newCommitID)
51
+
assert.Equal(t, "refs/pull/26595/head", results[6].refName.String())
52
+
assert.Equal(t, gitShortEmptySha, results[6].oldCommitID)
53
+
assert.Empty(t, results[6].newCommitID)
54
54
55
-
assert.EqualValues(t, "refs/pull/26595/merge", results[7].refName.String())
56
-
assert.EqualValues(t, gitShortEmptySha, results[7].oldCommitID)
57
-
assert.EqualValues(t, "", results[7].newCommitID)
55
+
assert.Equal(t, "refs/pull/26595/merge", results[7].refName.String())
56
+
assert.Equal(t, gitShortEmptySha, results[7].oldCommitID)
57
+
assert.Empty(t, results[7].newCommitID)
58
58
59
-
assert.EqualValues(t, "refs/pull/25873/head", results[8].refName.String())
60
-
assert.EqualValues(t, "e0639e38fb", results[8].oldCommitID)
61
-
assert.EqualValues(t, "6db2410489", results[8].newCommitID)
59
+
assert.Equal(t, "refs/pull/25873/head", results[8].refName.String())
60
+
assert.Equal(t, "e0639e38fb", results[8].oldCommitID)
61
+
assert.Equal(t, "6db2410489", results[8].newCommitID)
62
62
63
-
assert.EqualValues(t, "refs/pull/25873/merge", results[9].refName.String())
64
-
assert.EqualValues(t, "1c97ebc746", results[9].oldCommitID)
65
-
assert.EqualValues(t, "976d27d52f", results[9].newCommitID)
63
+
assert.Equal(t, "refs/pull/25873/merge", results[9].refName.String())
64
+
assert.Equal(t, "1c97ebc746", results[9].oldCommitID)
65
+
assert.Equal(t, "976d27d52f", results[9].newCommitID)
66
66
}
+6
-5
services/packages/cleanup/cleanup.go
+6
-5
services/packages/cleanup/cleanup.go
···
122
122
}
123
123
124
124
if anyVersionDeleted {
125
-
if pcr.Type == packages_model.TypeDebian {
125
+
switch pcr.Type {
126
+
case packages_model.TypeDebian:
126
127
if err := debian_service.BuildAllRepositoryFiles(ctx, pcr.OwnerID); err != nil {
127
128
return fmt.Errorf("CleanupRule [%d]: debian.BuildAllRepositoryFiles failed: %w", pcr.ID, err)
128
129
}
129
-
} else if pcr.Type == packages_model.TypeAlpine {
130
+
case packages_model.TypeAlpine:
130
131
if err := alpine_service.BuildAllRepositoryFiles(ctx, pcr.OwnerID); err != nil {
131
132
return fmt.Errorf("CleanupRule [%d]: alpine.BuildAllRepositoryFiles failed: %w", pcr.ID, err)
132
133
}
133
-
} else if pcr.Type == packages_model.TypeRpm {
134
+
case packages_model.TypeRpm:
134
135
if err := rpm_service.BuildAllRepositoryFiles(ctx, pcr.OwnerID); err != nil {
135
136
return fmt.Errorf("CleanupRule [%d]: rpm.BuildAllRepositoryFiles failed: %w", pcr.ID, err)
136
137
}
137
-
} else if pcr.Type == packages_model.TypeArch {
138
+
case packages_model.TypeArch:
138
139
if err := arch_service.BuildAllRepositoryFiles(ctx, pcr.OwnerID); err != nil {
139
140
return fmt.Errorf("CleanupRule [%d]: arch.BuildAllRepositoryFiles failed: %w", pcr.ID, err)
140
141
}
141
-
} else if pcr.Type == packages_model.TypeAlt {
142
+
case packages_model.TypeAlt:
142
143
if err := alt_service.BuildAllRepositoryFiles(ctx, pcr.OwnerID); err != nil {
143
144
return fmt.Errorf("CleanupRule [%d]: alt.BuildAllRepositoryFiles failed: %w", pcr.ID, err)
144
145
}
+1
-1
services/packages/cleanup/cleanup_sha256_test.go
+1
-1
services/packages/cleanup/cleanup_sha256_test.go
+1
-1
services/packages/container/blob_uploader.go
+1
-1
services/packages/container/blob_uploader.go
+1
-1
services/pull/check_test.go
+1
-1
services/pull/check_test.go
+1
-1
services/pull/review.go
+1
-1
services/pull/review.go
···
232
232
commit, err := gitRepo.LineBlame(head, gitRepo.Path, treePath, uint(line))
233
233
if err == nil {
234
234
commitID = commit.ID.String()
235
-
} else if !(strings.Contains(err.Error(), "exit status 128 - fatal: no such path") || notEnoughLines.MatchString(err.Error())) {
235
+
} else if !strings.Contains(err.Error(), "exit status 128 - fatal: no such path") && !notEnoughLines.MatchString(err.Error()) {
236
236
return nil, fmt.Errorf("LineBlame[%s, %s, %s, %d]: %w", pr.GetGitRefName(), gitRepo.Path, treePath, line, err)
237
237
}
238
238
}
+20
-20
services/release/release_test.go
+20
-20
services/release/release_test.go
···
138
138
}))
139
139
assert.NoError(t, repo_model.GetReleaseAttachments(db.DefaultContext, &release))
140
140
assert.Len(t, release.Attachments, 1)
141
-
assert.EqualValues(t, attach.UUID, release.Attachments[0].UUID)
142
-
assert.EqualValues(t, attach.Name, release.Attachments[0].Name)
143
-
assert.EqualValues(t, attach.ExternalURL, release.Attachments[0].ExternalURL)
141
+
assert.Equal(t, attach.UUID, release.Attachments[0].UUID)
142
+
assert.Equal(t, attach.Name, release.Attachments[0].Name)
143
+
assert.Equal(t, attach.ExternalURL, release.Attachments[0].ExternalURL)
144
144
145
145
release = repo_model.Release{
146
146
RepoID: repo.ID,
···
165
165
}))
166
166
assert.NoError(t, repo_model.GetReleaseAttachments(db.DefaultContext, &release))
167
167
assert.Len(t, release.Attachments, 1)
168
-
assert.EqualValues(t, "test", release.Attachments[0].Name)
169
-
assert.EqualValues(t, "https://forgejo.org/", release.Attachments[0].ExternalURL)
168
+
assert.Equal(t, "test", release.Attachments[0].Name)
169
+
assert.Equal(t, "https://forgejo.org/", release.Attachments[0].ExternalURL)
170
170
171
171
release = repo_model.Release{
172
172
RepoID: repo.ID,
···
318
318
}))
319
319
require.NoError(t, repo_model.GetReleaseAttachments(db.DefaultContext, release))
320
320
assert.Len(t, release.Attachments, 1)
321
-
assert.EqualValues(t, attach.UUID, release.Attachments[0].UUID)
322
-
assert.EqualValues(t, release.ID, release.Attachments[0].ReleaseID)
323
-
assert.EqualValues(t, attach.Name, release.Attachments[0].Name)
324
-
assert.EqualValues(t, attach.ExternalURL, release.Attachments[0].ExternalURL)
321
+
assert.Equal(t, attach.UUID, release.Attachments[0].UUID)
322
+
assert.Equal(t, release.ID, release.Attachments[0].ReleaseID)
323
+
assert.Equal(t, attach.Name, release.Attachments[0].Name)
324
+
assert.Equal(t, attach.ExternalURL, release.Attachments[0].ExternalURL)
325
325
326
326
// update the attachment name
327
327
require.NoError(t, UpdateRelease(db.DefaultContext, user, gitRepo, release, false, []*AttachmentChange{
···
334
334
release.Attachments = nil
335
335
require.NoError(t, repo_model.GetReleaseAttachments(db.DefaultContext, release))
336
336
assert.Len(t, release.Attachments, 1)
337
-
assert.EqualValues(t, attach.UUID, release.Attachments[0].UUID)
338
-
assert.EqualValues(t, release.ID, release.Attachments[0].ReleaseID)
339
-
assert.EqualValues(t, "test2.txt", release.Attachments[0].Name)
340
-
assert.EqualValues(t, attach.ExternalURL, release.Attachments[0].ExternalURL)
337
+
assert.Equal(t, attach.UUID, release.Attachments[0].UUID)
338
+
assert.Equal(t, release.ID, release.Attachments[0].ReleaseID)
339
+
assert.Equal(t, "test2.txt", release.Attachments[0].Name)
340
+
assert.Equal(t, attach.ExternalURL, release.Attachments[0].ExternalURL)
341
341
342
342
// delete the attachment
343
343
require.NoError(t, UpdateRelease(db.DefaultContext, user, gitRepo, release, false, []*AttachmentChange{
···
361
361
}))
362
362
assert.NoError(t, repo_model.GetReleaseAttachments(db.DefaultContext, release))
363
363
assert.Len(t, release.Attachments, 1)
364
-
assert.EqualValues(t, release.ID, release.Attachments[0].ReleaseID)
365
-
assert.EqualValues(t, "test", release.Attachments[0].Name)
366
-
assert.EqualValues(t, "https://forgejo.org/", release.Attachments[0].ExternalURL)
364
+
assert.Equal(t, release.ID, release.Attachments[0].ReleaseID)
365
+
assert.Equal(t, "test", release.Attachments[0].Name)
366
+
assert.Equal(t, "https://forgejo.org/", release.Attachments[0].ExternalURL)
367
367
externalAttachmentUUID := release.Attachments[0].UUID
368
368
369
369
// update the attachment name
···
378
378
release.Attachments = nil
379
379
assert.NoError(t, repo_model.GetReleaseAttachments(db.DefaultContext, release))
380
380
assert.Len(t, release.Attachments, 1)
381
-
assert.EqualValues(t, externalAttachmentUUID, release.Attachments[0].UUID)
382
-
assert.EqualValues(t, release.ID, release.Attachments[0].ReleaseID)
383
-
assert.EqualValues(t, "test2", release.Attachments[0].Name)
384
-
assert.EqualValues(t, "https://about.gitea.com/", release.Attachments[0].ExternalURL)
381
+
assert.Equal(t, externalAttachmentUUID, release.Attachments[0].UUID)
382
+
assert.Equal(t, release.ID, release.Attachments[0].ReleaseID)
383
+
assert.Equal(t, "test2", release.Attachments[0].Name)
384
+
assert.Equal(t, "https://about.gitea.com/", release.Attachments[0].ExternalURL)
385
385
}
386
386
387
387
func TestRelease_createTag(t *testing.T) {
+3
-3
services/repository/archiver/archiver_test.go
+3
-3
services/repository/archiver/archiver_test.go
···
36
36
bogusReq, err := NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit, git.ZIP)
37
37
require.NoError(t, err)
38
38
assert.NotNil(t, bogusReq)
39
-
assert.EqualValues(t, firstCommit+".zip", bogusReq.GetArchiveName())
39
+
assert.Equal(t, firstCommit+".zip", bogusReq.GetArchiveName())
40
40
41
41
// Check a series of bogus requests.
42
42
// Step 1, valid commit with a bad extension.
···
57
57
bogusReq, err = NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, "master", git.ZIP)
58
58
require.NoError(t, err)
59
59
assert.NotNil(t, bogusReq)
60
-
assert.EqualValues(t, "master.zip", bogusReq.GetArchiveName())
60
+
assert.Equal(t, "master.zip", bogusReq.GetArchiveName())
61
61
62
62
bogusReq, err = NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, "test/archive", git.ZIP)
63
63
require.NoError(t, err)
64
64
assert.NotNil(t, bogusReq)
65
-
assert.EqualValues(t, "test-archive.zip", bogusReq.GetArchiveName())
65
+
assert.Equal(t, "test-archive.zip", bogusReq.GetArchiveName())
66
66
67
67
// Now two valid requests, firstCommit with valid extensions.
68
68
zipReq, err := NewRequest(ctx, ctx.Repo.Repository.ID, ctx.Repo.GitRepo, firstCommit, git.ZIP)
+1
-1
services/repository/avatar_test.go
+1
-1
services/repository/avatar_test.go
+3
-3
services/repository/contributors_graph_test.go
+3
-3
services/repository/contributors_graph_test.go
···
53
53
keys = append(keys, k)
54
54
}
55
55
slices.Sort(keys)
56
-
assert.EqualValues(t, []string{
56
+
assert.Equal(t, []string{
57
57
"ethantkoenig@gmail.com",
58
58
"jimmy.praet@telenet.be",
59
59
"jon@allspice.io",
60
60
"total", // generated summary
61
61
}, keys)
62
62
63
-
assert.EqualValues(t, &ContributorData{
63
+
assert.Equal(t, &ContributorData{
64
64
Name: "Ethan Koenig",
65
65
AvatarLink: "/assets/img/avatar_default.png",
66
66
TotalCommits: 1,
···
73
73
},
74
74
},
75
75
}, data["ethantkoenig@gmail.com"])
76
-
assert.EqualValues(t, &ContributorData{
76
+
assert.Equal(t, &ContributorData{
77
77
Name: "Total",
78
78
AvatarLink: "",
79
79
TotalCommits: 3,
+2
-2
services/repository/files/content_test.go
+2
-2
services/repository/files/content_test.go
···
64
64
65
65
t.Run("Get README.md contents with GetContents(ctx, )", func(t *testing.T) {
66
66
fileContentResponse, err := GetContents(db.DefaultContext, repo, treePath, ref, false)
67
-
assert.EqualValues(t, expectedContentsResponse, fileContentResponse)
67
+
assert.Equal(t, expectedContentsResponse, fileContentResponse)
68
68
require.NoError(t, err)
69
69
})
70
70
71
71
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) {
72
72
fileContentResponse, err := GetContents(db.DefaultContext, repo, treePath, "", false)
73
-
assert.EqualValues(t, expectedContentsResponse, fileContentResponse)
73
+
assert.Equal(t, expectedContentsResponse, fileContentResponse)
74
74
require.NoError(t, err)
75
75
})
76
76
}
+2
-2
services/repository/files/diff_test.go
+2
-2
services/repository/files/diff_test.go
···
124
124
require.NoError(t, err)
125
125
bs, err := json.Marshal(diff)
126
126
require.NoError(t, err)
127
-
assert.EqualValues(t, string(expectedBs), string(bs))
127
+
assert.Equal(t, string(expectedBs), string(bs))
128
128
})
129
129
130
130
t.Run("empty branch, same results", func(t *testing.T) {
···
134
134
require.NoError(t, err)
135
135
bs, err := json.Marshal(diff)
136
136
require.NoError(t, err)
137
-
assert.EqualValues(t, expectedBs, bs)
137
+
assert.Equal(t, expectedBs, bs)
138
138
})
139
139
}
140
140
+2
-2
services/repository/files/file_test.go
+2
-2
services/repository/files/file_test.go
···
14
14
name := "this/is/test"
15
15
cleanName := CleanUploadFileName(name)
16
16
expectedCleanName := name
17
-
assert.EqualValues(t, expectedCleanName, cleanName)
17
+
assert.Equal(t, expectedCleanName, cleanName)
18
18
})
19
19
20
20
t.Run("Clean a .git path", func(t *testing.T) {
21
21
name := "this/is/test/.git"
22
22
cleanName := CleanUploadFileName(name)
23
23
expectedCleanName := ""
24
-
assert.EqualValues(t, expectedCleanName, cleanName)
24
+
assert.Equal(t, expectedCleanName, cleanName)
25
25
})
26
26
}
+1
-1
services/repository/files/tree_test.go
+1
-1
services/repository/files/tree_test.go
+1
-1
services/repository/lfs.go
+1
-1
services/repository/lfs.go
···
76
76
77
77
err = git_model.IterateLFSMetaObjectsForRepo(ctx, repo.ID, func(ctx context.Context, metaObject *git_model.LFSMetaObject) error {
78
78
total++
79
-
pointerSha := git.ComputeBlobHash(objectFormat, []byte(metaObject.Pointer.StringContent()))
79
+
pointerSha := git.ComputeBlobHash(objectFormat, []byte(metaObject.StringContent()))
80
80
81
81
if gitRepo.IsObjectExist(pointerSha.String()) {
82
82
return git_model.MarkLFSMetaObject(ctx, metaObject.ID)
+4
-4
services/user/avatar_test.go
+4
-4
services/user/avatar_test.go
···
42
42
err := UploadAvatar(db.DefaultContext, user, buff.Bytes())
43
43
require.NoError(t, err)
44
44
verification := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
45
-
assert.NotEqual(t, "", verification.Avatar)
45
+
assert.NotEmpty(t, verification.Avatar)
46
46
47
47
// fail to delete ...
48
48
storage.Avatars = storage.UninitializedStorage
···
60
60
61
61
// ... the avatar is removed from the database
62
62
verification = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
63
-
assert.Equal(t, "", verification.Avatar)
63
+
assert.Empty(t, verification.Avatar)
64
64
})
65
65
66
66
t.Run("Success", func(t *testing.T) {
···
70
70
err := UploadAvatar(db.DefaultContext, user, buff.Bytes())
71
71
require.NoError(t, err)
72
72
verification := unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
73
-
assert.NotEqual(t, "", verification.Avatar)
73
+
assert.NotEmpty(t, verification.Avatar)
74
74
75
75
err = DeleteAvatar(db.DefaultContext, user)
76
76
require.NoError(t, err)
77
77
78
78
verification = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1})
79
-
assert.Equal(t, "", verification.Avatar)
79
+
assert.Empty(t, verification.Avatar)
80
80
})
81
81
}
+1
-1
services/user/user_test.go
+1
-1
services/user/user_test.go
···
195
195
196
196
redirectUID, err := user_model.LookupUserRedirect(db.DefaultContext, oldUsername)
197
197
require.NoError(t, err)
198
-
assert.EqualValues(t, user.ID, redirectUID)
198
+
assert.Equal(t, user.ID, redirectUID)
199
199
200
200
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerID: user.ID, OwnerName: user.Name})
201
201
})
+1
-1
services/webhook/default_test.go
+1
-1
services/webhook/default_test.go
···
237
237
assert.Equal(t, 12, j.Get("number").MustBeValid().ToInt())
238
238
assert.Equal(t, "http://localhost:3000/test/repo/pulls/12", j.Get("html_url").MustBeValid().ToString())
239
239
assert.Equal(t, jsoniter.NilValue, j.Get("updated_at").ValueType())
240
-
assert.Equal(t, "", j.Get("state").MustBeValid().ToString())
240
+
assert.Empty(t, j.Get("state").MustBeValid().ToString())
241
241
assert.Equal(t, "Fix bug", j.Get("title").MustBeValid().ToString())
242
242
assert.Equal(t, "fixes bug #2", j.Get("body").MustBeValid().ToString())
243
243
+1
-1
services/webhook/deliver_test.go
+1
-1
services/webhook/deliver_test.go
···
137
137
case "/webhook/66d222a5d6349e1311f551e50722d837e30fce98":
138
138
// Version 1
139
139
assert.Equal(t, "push", r.Header.Get("X-GitHub-Event"))
140
-
assert.Equal(t, "", r.Header.Get("Content-Type"))
140
+
assert.Empty(t, r.Header.Get("Content-Type"))
141
141
body, err := io.ReadAll(r.Body)
142
142
require.NoError(t, err)
143
143
assert.Equal(t, `{"data": 42}`, string(body))
+8
-6
services/webhook/general.go
+8
-6
services/webhook/general.go
···
37
37
for i, user := range assignList {
38
38
assignStringList[i] = user.UserName
39
39
}
40
-
if p.Action == api.HookIssueAssigned {
40
+
switch p.Action {
41
+
case api.HookIssueAssigned:
41
42
operateResult = fmt.Sprintf("%s assign this to %s", p.Sender.UserName, assignList[len(assignList)-1].UserName)
42
-
} else if p.Action == api.HookIssueUnassigned {
43
+
case api.HookIssueUnassigned:
43
44
operateResult = fmt.Sprintf("%s unassigned this for someone", p.Sender.UserName)
44
-
} else if p.Action == api.HookIssueMilestoned {
45
+
case api.HookIssueMilestoned:
45
46
operateResult = fmt.Sprintf("%s/milestone/%d", p.Repository.HTMLURL, p.PullRequest.Milestone.ID)
46
47
}
47
48
link = p.PullRequest.HTMLURL
···
62
63
for i, user := range assignList {
63
64
assignStringList[i] = user.UserName
64
65
}
65
-
if p.Action == api.HookIssueAssigned {
66
+
switch p.Action {
67
+
case api.HookIssueAssigned:
66
68
operateResult = fmt.Sprintf("%s assign this to %s", p.Sender.UserName, assignList[len(assignList)-1].UserName)
67
-
} else if p.Action == api.HookIssueUnassigned {
69
+
case api.HookIssueUnassigned:
68
70
operateResult = fmt.Sprintf("%s unassigned this for someone", p.Sender.UserName)
69
-
} else if p.Action == api.HookIssueMilestoned {
71
+
case api.HookIssueMilestoned:
70
72
operateResult = fmt.Sprintf("%s/milestone/%d", p.Repository.HTMLURL, p.Issue.Milestone.ID)
71
73
}
72
74
link = p.Issue.HTMLURL
+2
-2
services/webhook/msteams_test.go
+2
-2
services/webhook/msteams_test.go
···
335
335
assert.Equal(t, "[test/repo] New wiki page 'index' (Wiki change comment)", pl.Summary)
336
336
assert.Len(t, pl.Sections, 1)
337
337
assert.Equal(t, "user1", pl.Sections[0].ActivitySubtitle)
338
-
assert.Equal(t, "", pl.Sections[0].Text)
338
+
assert.Empty(t, pl.Sections[0].Text)
339
339
assert.Len(t, pl.Sections[0].Facts, 2)
340
340
for _, fact := range pl.Sections[0].Facts {
341
341
if fact.Name == "Repository:" {
···
356
356
assert.Equal(t, "[test/repo] Wiki page 'index' edited (Wiki change comment)", pl.Summary)
357
357
assert.Len(t, pl.Sections, 1)
358
358
assert.Equal(t, "user1", pl.Sections[0].ActivitySubtitle)
359
-
assert.Equal(t, "", pl.Sections[0].Text)
359
+
assert.Empty(t, pl.Sections[0].Text)
360
360
assert.Len(t, pl.Sections[0].Facts, 2)
361
361
for _, fact := range pl.Sections[0].Facts {
362
362
if fact.Name == "Repository:" {
+2
-2
services/webhook/notifier_test.go
+2
-2
services/webhook/notifier_test.go
···
90
90
var payloadContent structs.PushPayload
91
91
require.NoError(t, json.Unmarshal([]byte(hookTask.PayloadContent), &payloadContent))
92
92
assert.Len(t, payloadContent.Commits, 1)
93
-
assert.EqualValues(t, "2c54faec6c45d31c1abfaecdab471eac6633738a", payloadContent.Commits[0].ID)
93
+
assert.Equal(t, "2c54faec6c45d31c1abfaecdab471eac6633738a", payloadContent.Commits[0].ID)
94
94
})
95
95
}
96
96
···
129
129
var payloadContent structs.PushPayload
130
130
require.NoError(t, json.Unmarshal([]byte(hookTask.PayloadContent), &payloadContent))
131
131
assert.Len(t, payloadContent.Commits, 1)
132
-
assert.EqualValues(t, "2c54faec6c45d31c1abfaecdab471eac6633738a", payloadContent.Commits[0].ID)
132
+
assert.Equal(t, "2c54faec6c45d31c1abfaecdab471eac6633738a", payloadContent.Commits[0].ID)
133
133
})
134
134
}
+11
-11
services/wiki/wiki_test.go
+11
-11
services/wiki/wiki_test.go
···
26
26
27
27
func TestWebPathSegments(t *testing.T) {
28
28
a := WebPathSegments("a%2Fa/b+c/d-e/f-g.-")
29
-
assert.EqualValues(t, []string{"a/a", "b c", "d e", "f-g"}, a)
29
+
assert.Equal(t, []string{"a/a", "b c", "d e", "f-g"}, a)
30
30
}
31
31
32
32
func TestUserTitleToWebPath(t *testing.T) {
···
63
63
{"a b", "a%20b.md"},
64
64
} {
65
65
_, displayName := WebPathToUserTitle(test.WebPath)
66
-
assert.EqualValues(t, test.Expected, displayName)
66
+
assert.Equal(t, test.Expected, displayName)
67
67
}
68
68
}
69
69
···
80
80
{"2000-01-02-meeting.md", "2000-01-02+meeting"},
81
81
{"2000-01-02 meeting.-.md", "2000-01-02%20meeting.-"},
82
82
} {
83
-
assert.EqualValues(t, test.Expected, WebPathToGitPath(test.WikiName))
83
+
assert.Equal(t, test.Expected, WebPathToGitPath(test.WikiName))
84
84
}
85
85
}
86
86
···
134
134
_, userTitle1 := WebPathToUserTitle(webPath1)
135
135
gitPath1 := WebPathToGitPath(webPath1)
136
136
137
-
assert.EqualValues(t, userTitle, userTitle1, "UserTitle for userTitle: %q", userTitle)
138
-
assert.EqualValues(t, webPath, webPath1, "WebPath for userTitle: %q", userTitle)
139
-
assert.EqualValues(t, gitPath, gitPath1, "GitPath for userTitle: %q", userTitle)
137
+
assert.Equal(t, userTitle, userTitle1, "UserTitle for userTitle: %q", userTitle)
138
+
assert.Equal(t, webPath, webPath1, "WebPath for userTitle: %q", userTitle)
139
+
assert.Equal(t, gitPath, gitPath1, "GitPath for userTitle: %q", userTitle)
140
140
}
141
141
}
142
142
···
175
175
gitPath := WebPathToGitPath(webPath)
176
176
entry, err := masterTree.GetTreeEntryByPath(gitPath)
177
177
require.NoError(t, err)
178
-
assert.EqualValues(t, gitPath, entry.Name(), "%s not added correctly", userTitle)
178
+
assert.Equal(t, gitPath, entry.Name(), "%s not added correctly", userTitle)
179
179
})
180
180
}
181
181
···
220
220
gitPath := WebPathToGitPath(webPath)
221
221
entry, err := masterTree.GetTreeEntryByPath(gitPath)
222
222
require.NoError(t, err)
223
-
assert.EqualValues(t, gitPath, entry.Name(), "%s not edited correctly", newWikiName)
223
+
assert.Equal(t, gitPath, entry.Name(), "%s not edited correctly", newWikiName)
224
224
225
225
if newWikiName != "Home" {
226
226
_, err := masterTree.GetTreeEntryByPath("Home.md")
···
289
289
t.Errorf("expect to find an escaped file but we could not detect one")
290
290
}
291
291
}
292
-
assert.EqualValues(t, tt.wikiPath, newWikiPath)
292
+
assert.Equal(t, tt.wikiPath, newWikiPath)
293
293
})
294
294
}
295
295
}
···
311
311
existence, newWikiPath, err := prepareGitPath(gitRepo, "master", "Home")
312
312
assert.False(t, existence)
313
313
require.NoError(t, err)
314
-
assert.EqualValues(t, "Home.md", newWikiPath)
314
+
assert.Equal(t, "Home.md", newWikiPath)
315
315
}
316
316
317
317
func TestWebPathConversion(t *testing.T) {
318
318
assert.Equal(t, "path/wiki", WebPathToURLPath(WebPath("path/wiki")))
319
319
assert.Equal(t, "wiki", WebPathToURLPath(WebPath("wiki")))
320
-
assert.Equal(t, "", WebPathToURLPath(WebPath("")))
320
+
assert.Empty(t, WebPathToURLPath(WebPath("")))
321
321
}
322
322
323
323
func TestWebPathFromRequest(t *testing.T) {
+4
-4
tests/integration/actions_variables_test.go
+4
-4
tests/integration/actions_variables_test.go
···
64
64
resp := sess.MakeRequest(t, req, http.StatusBadRequest)
65
65
var error errorJSON
66
66
DecodeJSON(t, resp, &error)
67
-
assert.EqualValues(t, "Failed to find the variable.", error.Error)
67
+
assert.Equal(t, "Failed to find the variable.", error.Error)
68
68
} else {
69
69
sess.MakeRequest(t, req, http.StatusOK)
70
70
flashCookie := sess.GetCookie(forgejo_context.CookieNameFlash)
71
71
assert.NotNil(t, flashCookie)
72
-
assert.EqualValues(t, "success%3DThe%2Bvariable%2Bhas%2Bbeen%2Bedited.", flashCookie.Value)
72
+
assert.Equal(t, "success%3DThe%2Bvariable%2Bhas%2Bbeen%2Bedited.", flashCookie.Value)
73
73
}
74
74
75
75
req = NewRequestWithValues(t, "POST", baseURL+fmt.Sprintf("/%d/delete", id), map[string]string{
···
79
79
resp := sess.MakeRequest(t, req, http.StatusBadRequest)
80
80
var error errorJSON
81
81
DecodeJSON(t, resp, &error)
82
-
assert.EqualValues(t, "Failed to find the variable.", error.Error)
82
+
assert.Equal(t, "Failed to find the variable.", error.Error)
83
83
} else {
84
84
sess.MakeRequest(t, req, http.StatusOK)
85
85
flashCookie := sess.GetCookie(forgejo_context.CookieNameFlash)
86
86
assert.NotNil(t, flashCookie)
87
-
assert.EqualValues(t, "success%3DThe%2Bvariable%2Bhas%2Bbeen%2Bremoved.", flashCookie.Value)
87
+
assert.Equal(t, "success%3DThe%2Bvariable%2Bhas%2Bbeen%2Bremoved.", flashCookie.Value)
88
88
}
89
89
}
90
90
+1
-1
tests/integration/admin_user_test.go
+1
-1
tests/integration/admin_user_test.go
···
38
38
39
39
// 6th column is the 2FA column.
40
40
// One user that has TOTP and another user that has WebAuthn.
41
-
assert.EqualValues(t, 2, htmlDoc.Find(".admin-setting-content table tbody tr td:nth-child(6) .octicon-check").Length())
41
+
assert.Equal(t, 2, htmlDoc.Find(".admin-setting-content table tbody tr td:nth-child(6) .octicon-check").Length())
42
42
})
43
43
44
44
t.Run("Normal user", func(t *testing.T) {
+1
-1
tests/integration/api_admin_actions_test.go
+1
-1
tests/integration/api_admin_actions_test.go
+1
-1
tests/integration/api_admin_test.go
+1
-1
tests/integration/api_admin_test.go
···
211
211
212
212
errMap := make(map[string]any)
213
213
json.Unmarshal(resp.Body.Bytes(), &errMap)
214
-
assert.EqualValues(t, "e-mail invalid [email: ]", errMap["message"].(string))
214
+
assert.Equal(t, "e-mail invalid [email: ]", errMap["message"].(string))
215
215
216
216
user2 = unittest.AssertExistsAndLoadBean(t, &user_model.User{LoginName: "user2"})
217
217
assert.False(t, user2.IsRestricted)
+7
-7
tests/integration/api_branch_test.go
+7
-7
tests/integration/api_branch_test.go
···
25
25
AddTokenAuth(token)
26
26
resp := MakeRequest(t, req, NoExpectedStatus)
27
27
if !exists {
28
-
assert.EqualValues(t, http.StatusNotFound, resp.Code)
28
+
assert.Equal(t, http.StatusNotFound, resp.Code)
29
29
return
30
30
}
31
-
assert.EqualValues(t, http.StatusOK, resp.Code)
31
+
assert.Equal(t, http.StatusOK, resp.Code)
32
32
var branch api.Branch
33
33
DecodeJSON(t, resp, &branch)
34
-
assert.EqualValues(t, branchName, branch.Name)
34
+
assert.Equal(t, branchName, branch.Name)
35
35
assert.True(t, branch.UserCanPush)
36
36
assert.True(t, branch.UserCanMerge)
37
37
}
···
45
45
if resp.Code == http.StatusOK {
46
46
var branchProtection api.BranchProtection
47
47
DecodeJSON(t, resp, &branchProtection)
48
-
assert.EqualValues(t, branchName, branchProtection.RuleName)
48
+
assert.Equal(t, branchName, branchProtection.RuleName)
49
49
return &branchProtection
50
50
}
51
51
return nil
···
61
61
if resp.Code == http.StatusCreated {
62
62
var branchProtection api.BranchProtection
63
63
DecodeJSON(t, resp, &branchProtection)
64
-
assert.EqualValues(t, branchName, branchProtection.RuleName)
64
+
assert.Equal(t, branchName, branchProtection.RuleName)
65
65
}
66
66
}
67
67
···
74
74
if resp.Code == http.StatusOK {
75
75
var branchProtection api.BranchProtection
76
76
DecodeJSON(t, resp, &branchProtection)
77
-
assert.EqualValues(t, branchName, branchProtection.RuleName)
77
+
assert.Equal(t, branchName, branchProtection.RuleName)
78
78
}
79
79
}
80
80
···
182
182
DecodeJSON(t, resp, &branch)
183
183
184
184
if resp.Result().StatusCode == http.StatusCreated {
185
-
assert.EqualValues(t, newBranch, branch.Name)
185
+
assert.Equal(t, newBranch, branch.Name)
186
186
}
187
187
188
188
return resp.Result().StatusCode == status
+3
-3
tests/integration/api_comment_test.go
+3
-3
tests/integration/api_comment_test.go
···
115
115
116
116
var updatedComment api.Comment
117
117
DecodeJSON(t, resp, &updatedComment)
118
-
assert.EqualValues(t, commentBody, updatedComment.Body)
118
+
assert.Equal(t, commentBody, updatedComment.Body)
119
119
unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: updatedComment.ID, IssueID: issue.ID, Content: commentBody})
120
120
121
121
urlStr = fmt.Sprintf("/api/v1/repos/%s/%s/issues/%d/comments",
···
373
373
374
374
var updatedComment api.Comment
375
375
DecodeJSON(t, resp, &updatedComment)
376
-
assert.EqualValues(t, comment.ID, updatedComment.ID)
377
-
assert.EqualValues(t, newCommentBody, updatedComment.Body)
376
+
assert.Equal(t, comment.ID, updatedComment.ID)
377
+
assert.Equal(t, newCommentBody, updatedComment.Body)
378
378
unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: comment.ID, IssueID: issue.ID, Content: newCommentBody})
379
379
}
380
380
+2
-2
tests/integration/api_fork_test.go
+2
-2
tests/integration/api_fork_test.go
···
133
133
DecodeJSON(t, resp, &forks)
134
134
135
135
assert.Empty(t, forks)
136
-
assert.EqualValues(t, "0", resp.Header().Get("X-Total-Count"))
136
+
assert.Equal(t, "0", resp.Header().Get("X-Total-Count"))
137
137
})
138
138
139
139
t.Run("Logged in", func(t *testing.T) {
···
146
146
DecodeJSON(t, resp, &forks)
147
147
148
148
assert.Len(t, forks, 1)
149
-
assert.EqualValues(t, "1", resp.Header().Get("X-Total-Count"))
149
+
assert.Equal(t, "1", resp.Header().Get("X-Total-Count"))
150
150
})
151
151
}
+6
-6
tests/integration/api_gpg_keys_test.go
+6
-6
tests/integration/api_gpg_keys_test.go
···
86
86
assert.Len(t, keys, 1)
87
87
88
88
primaryKey1 := keys[0] // Primary key 1
89
-
assert.EqualValues(t, "38EA3BCED732982C", primaryKey1.KeyID)
89
+
assert.Equal(t, "38EA3BCED732982C", primaryKey1.KeyID)
90
90
assert.Len(t, primaryKey1.Emails, 1)
91
-
assert.EqualValues(t, "user2@example.com", primaryKey1.Emails[0].Email)
91
+
assert.Equal(t, "user2@example.com", primaryKey1.Emails[0].Email)
92
92
assert.True(t, primaryKey1.Emails[0].Verified)
93
93
94
94
subKey := primaryKey1.SubsKey[0] // Subkey of 38EA3BCED732982C
95
-
assert.EqualValues(t, "70D7C694D17D03AD", subKey.KeyID)
95
+
assert.Equal(t, "70D7C694D17D03AD", subKey.KeyID)
96
96
assert.Empty(t, subKey.Emails)
97
97
98
98
var key api.GPGKey
···
100
100
AddTokenAuth(tokenWithGPGKeyScope)
101
101
resp = MakeRequest(t, req, http.StatusOK)
102
102
DecodeJSON(t, resp, &key)
103
-
assert.EqualValues(t, "38EA3BCED732982C", key.KeyID)
103
+
assert.Equal(t, "38EA3BCED732982C", key.KeyID)
104
104
assert.Len(t, key.Emails, 1)
105
-
assert.EqualValues(t, "user2@example.com", key.Emails[0].Email)
105
+
assert.Equal(t, "user2@example.com", key.Emails[0].Email)
106
106
assert.True(t, key.Emails[0].Verified)
107
107
108
108
req = NewRequest(t, "GET", "/api/v1/user/gpg_keys/"+strconv.FormatInt(subKey.ID, 10)). // Subkey of 38EA3BCED732982C
109
109
AddTokenAuth(tokenWithGPGKeyScope)
110
110
resp = MakeRequest(t, req, http.StatusOK)
111
111
DecodeJSON(t, resp, &key)
112
-
assert.EqualValues(t, "70D7C694D17D03AD", key.KeyID)
112
+
assert.Equal(t, "70D7C694D17D03AD", key.KeyID)
113
113
assert.Empty(t, key.Emails)
114
114
})
115
115
+1
-1
tests/integration/api_helper_for_declarative_test.go
+1
-1
tests/integration/api_helper_for_declarative_test.go
+10
-10
tests/integration/api_issue_label_test.go
+10
-10
tests/integration/api_issue_label_test.go
···
41
41
apiLabel := new(api.Label)
42
42
DecodeJSON(t, resp, &apiLabel)
43
43
dbLabel := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: apiLabel.ID, RepoID: repo.ID})
44
-
assert.EqualValues(t, dbLabel.Name, apiLabel.Name)
45
-
assert.EqualValues(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
44
+
assert.Equal(t, dbLabel.Name, apiLabel.Name)
45
+
assert.Equal(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
46
46
47
47
req = NewRequestWithJSON(t, "POST", urlStr, &api.CreateLabelOption{
48
48
Name: "TestL 2",
···
70
70
AddTokenAuth(token)
71
71
resp = MakeRequest(t, req, http.StatusOK)
72
72
DecodeJSON(t, resp, &apiLabel)
73
-
assert.EqualValues(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
73
+
assert.Equal(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
74
74
75
75
// EditLabel
76
76
newName := "LabelNewName"
···
82
82
}).AddTokenAuth(token)
83
83
resp = MakeRequest(t, req, http.StatusOK)
84
84
DecodeJSON(t, resp, &apiLabel)
85
-
assert.EqualValues(t, newColor, apiLabel.Color)
85
+
assert.Equal(t, newColor, apiLabel.Color)
86
86
req = NewRequestWithJSON(t, "PATCH", singleURLStr, &api.EditLabelOption{
87
87
Color: &newColorWrong,
88
88
}).AddTokenAuth(token)
···
211
211
var apiLabels []*api.Label
212
212
DecodeJSON(t, resp, &apiLabels)
213
213
if assert.Len(t, apiLabels, 1) {
214
-
assert.EqualValues(t, label.ID, apiLabels[0].ID)
214
+
assert.Equal(t, label.ID, apiLabels[0].ID)
215
215
}
216
216
217
217
unittest.AssertCount(t, &issues_model.IssueLabel{IssueID: issue.ID}, 1)
···
237
237
var apiLabels []*api.Label
238
238
DecodeJSON(t, resp, &apiLabels)
239
239
if assert.Len(t, apiLabels, 1) {
240
-
assert.EqualValues(t, label.Name, apiLabels[0].Name)
240
+
assert.Equal(t, label.Name, apiLabels[0].Name)
241
241
}
242
242
}
243
243
···
261
261
apiLabel := new(api.Label)
262
262
DecodeJSON(t, resp, &apiLabel)
263
263
dbLabel := unittest.AssertExistsAndLoadBean(t, &issues_model.Label{ID: apiLabel.ID, OrgID: owner.ID})
264
-
assert.EqualValues(t, dbLabel.Name, apiLabel.Name)
265
-
assert.EqualValues(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
264
+
assert.Equal(t, dbLabel.Name, apiLabel.Name)
265
+
assert.Equal(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
266
266
267
267
req = NewRequestWithJSON(t, "POST", urlStr, &api.CreateLabelOption{
268
268
Name: "TestL 2",
···
290
290
AddTokenAuth(token)
291
291
resp = MakeRequest(t, req, http.StatusOK)
292
292
DecodeJSON(t, resp, &apiLabel)
293
-
assert.EqualValues(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
293
+
assert.Equal(t, strings.TrimLeft(dbLabel.Color, "#"), apiLabel.Color)
294
294
295
295
// EditLabel
296
296
newName := "LabelNewName"
···
302
302
}).AddTokenAuth(token)
303
303
resp = MakeRequest(t, req, http.StatusOK)
304
304
DecodeJSON(t, resp, &apiLabel)
305
-
assert.EqualValues(t, newColor, apiLabel.Color)
305
+
assert.Equal(t, newColor, apiLabel.Color)
306
306
req = NewRequestWithJSON(t, "PATCH", singleURLStr, &api.EditLabelOption{
307
307
Color: &newColorWrong,
308
308
}).AddTokenAuth(token)
+1
-1
tests/integration/api_issue_milestone_test.go
+1
-1
tests/integration/api_issue_milestone_test.go
···
71
71
AddTokenAuth(token)
72
72
resp = MakeRequest(t, req, http.StatusOK)
73
73
DecodeJSON(t, resp, &apiMilestone)
74
-
assert.EqualValues(t, apiMilestones[2], apiMilestone)
74
+
assert.Equal(t, apiMilestones[2], apiMilestone)
75
75
76
76
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/%s/milestones?state=%s&name=%s", owner.Name, repo.Name, "all", "milestone2")).
77
77
AddTokenAuth(token)
+5
-5
tests/integration/api_issue_stopwatch_test.go
+5
-5
tests/integration/api_issue_stopwatch_test.go
···
35
35
stopwatch := unittest.AssertExistsAndLoadBean(t, &issues_model.Stopwatch{UserID: owner.ID})
36
36
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: stopwatch.IssueID})
37
37
if assert.Len(t, apiWatches, 1) {
38
-
assert.EqualValues(t, stopwatch.CreatedUnix.AsTime().Unix(), apiWatches[0].Created.Unix())
39
-
assert.EqualValues(t, issue.Index, apiWatches[0].IssueIndex)
40
-
assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle)
41
-
assert.EqualValues(t, repo.Name, apiWatches[0].RepoName)
42
-
assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
38
+
assert.Equal(t, stopwatch.CreatedUnix.AsTime().Unix(), apiWatches[0].Created.Unix())
39
+
assert.Equal(t, issue.Index, apiWatches[0].IssueIndex)
40
+
assert.Equal(t, issue.Title, apiWatches[0].IssueTitle)
41
+
assert.Equal(t, repo.Name, apiWatches[0].RepoName)
42
+
assert.Equal(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
43
43
assert.Positive(t, apiWatches[0].Seconds)
44
44
}
45
45
}
+4
-4
tests/integration/api_issue_subscription_test.go
+4
-4
tests/integration/api_issue_subscription_test.go
···
43
43
wi := new(api.WatchInfo)
44
44
DecodeJSON(t, resp, wi)
45
45
46
-
assert.EqualValues(t, isWatching, wi.Subscribed)
47
-
assert.EqualValues(t, !isWatching, wi.Ignored)
48
-
assert.EqualValues(t, issue.APIURL(db.DefaultContext)+"/subscriptions", wi.URL)
46
+
assert.Equal(t, isWatching, wi.Subscribed)
47
+
assert.Equal(t, !isWatching, wi.Ignored)
48
+
assert.Equal(t, issue.APIURL(db.DefaultContext)+"/subscriptions", wi.URL)
49
49
assert.EqualValues(t, issue.CreatedUnix, wi.CreatedAt.Unix())
50
-
assert.EqualValues(t, issueRepo.APIURL(), wi.RepositoryURL)
50
+
assert.Equal(t, issueRepo.APIURL(), wi.RepositoryURL)
51
51
}
52
52
53
53
testSubscription(issue1, true)
+2
-2
tests/integration/api_issue_test.go
+2
-2
tests/integration/api_issue_test.go
···
506
506
req = NewRequest(t, "GET", link.String()).AddTokenAuth(token)
507
507
resp = MakeRequest(t, req, http.StatusOK)
508
508
DecodeJSON(t, resp, &apiIssues)
509
-
assert.EqualValues(t, "22", resp.Header().Get("X-Total-Count"))
509
+
assert.Equal(t, "22", resp.Header().Get("X-Total-Count"))
510
510
assert.Len(t, apiIssues, 20)
511
511
512
512
query.Add("limit", "10")
···
514
514
req = NewRequest(t, "GET", link.String()).AddTokenAuth(token)
515
515
resp = MakeRequest(t, req, http.StatusOK)
516
516
DecodeJSON(t, resp, &apiIssues)
517
-
assert.EqualValues(t, "22", resp.Header().Get("X-Total-Count"))
517
+
assert.Equal(t, "22", resp.Header().Get("X-Total-Count"))
518
518
assert.Len(t, apiIssues, 10)
519
519
520
520
query = url.Values{"assigned": {"true"}, "state": {"all"}}
+3
-3
tests/integration/api_issue_tracked_time_test.go
+3
-3
tests/integration/api_issue_tracked_time_test.go
···
42
42
43
43
for i, time := range expect {
44
44
assert.Equal(t, time.ID, apiTimes[i].ID)
45
-
assert.EqualValues(t, issue2.Title, apiTimes[i].Issue.Title)
46
-
assert.EqualValues(t, issue2.ID, apiTimes[i].IssueID)
45
+
assert.Equal(t, issue2.Title, apiTimes[i].Issue.Title)
46
+
assert.Equal(t, issue2.ID, apiTimes[i].IssueID)
47
47
assert.Equal(t, time.Created.Unix(), apiTimes[i].Created.Unix())
48
48
assert.Equal(t, time.Time, apiTimes[i].Time)
49
49
user, err := user_model.GetUserByID(db.DefaultContext, time.UserID)
···
126
126
DecodeJSON(t, resp, &apiNewTime)
127
127
128
128
assert.EqualValues(t, 33, apiNewTime.Time)
129
-
assert.EqualValues(t, user2.ID, apiNewTime.UserID)
129
+
assert.Equal(t, user2.ID, apiNewTime.UserID)
130
130
assert.EqualValues(t, 947688818, apiNewTime.Created.Unix())
131
131
}
+3
-3
tests/integration/api_notification_test.go
+3
-3
tests/integration/api_notification_test.go
···
105
105
assert.EqualValues(t, 5, apiN.ID)
106
106
assert.False(t, apiN.Pinned)
107
107
assert.True(t, apiN.Unread)
108
-
assert.EqualValues(t, "issue4", apiN.Subject.Title)
108
+
assert.Equal(t, "issue4", apiN.Subject.Title)
109
109
assert.EqualValues(t, "Issue", apiN.Subject.Type)
110
-
assert.EqualValues(t, thread5.Issue.APIURL(db.DefaultContext), apiN.Subject.URL)
111
-
assert.EqualValues(t, thread5.Repository.HTMLURL(), apiN.Repository.HTMLURL)
110
+
assert.Equal(t, thread5.Issue.APIURL(db.DefaultContext), apiN.Subject.URL)
111
+
assert.Equal(t, thread5.Repository.HTMLURL(), apiN.Repository.HTMLURL)
112
112
113
113
MakeRequest(t, NewRequest(t, "GET", "/api/v1/notifications/new"), http.StatusUnauthorized)
114
114
+10
-10
tests/integration/api_oauth2_apps_test.go
+10
-10
tests/integration/api_oauth2_apps_test.go
···
43
43
var createdApp *api.OAuth2Application
44
44
DecodeJSON(t, resp, &createdApp)
45
45
46
-
assert.EqualValues(t, appBody.Name, createdApp.Name)
46
+
assert.Equal(t, appBody.Name, createdApp.Name)
47
47
assert.Len(t, createdApp.ClientSecret, 56)
48
48
assert.Len(t, createdApp.ClientID, 36)
49
49
assert.True(t, createdApp.ConfidentialClient)
50
50
assert.NotEmpty(t, createdApp.Created)
51
-
assert.EqualValues(t, appBody.RedirectURIs[0], createdApp.RedirectURIs[0])
51
+
assert.Equal(t, appBody.RedirectURIs[0], createdApp.RedirectURIs[0])
52
52
unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{UID: user.ID, Name: createdApp.Name})
53
53
}
54
54
···
74
74
DecodeJSON(t, resp, &appList)
75
75
expectedApp := appList[0]
76
76
77
-
assert.EqualValues(t, expectedApp.Name, existApp.Name)
78
-
assert.EqualValues(t, expectedApp.ClientID, existApp.ClientID)
77
+
assert.Equal(t, expectedApp.Name, existApp.Name)
78
+
assert.Equal(t, expectedApp.ClientID, existApp.ClientID)
79
79
assert.Equal(t, expectedApp.ConfidentialClient, existApp.ConfidentialClient)
80
80
assert.Len(t, expectedApp.ClientID, 36)
81
81
assert.Empty(t, expectedApp.ClientSecret)
82
-
assert.EqualValues(t, expectedApp.RedirectURIs[0], existApp.RedirectURIs[0])
82
+
assert.Equal(t, expectedApp.RedirectURIs[0], existApp.RedirectURIs[0])
83
83
unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: expectedApp.ID, Name: expectedApp.Name})
84
84
}
85
85
···
128
128
DecodeJSON(t, resp, &app)
129
129
expectedApp := app
130
130
131
-
assert.EqualValues(t, expectedApp.Name, existApp.Name)
132
-
assert.EqualValues(t, expectedApp.ClientID, existApp.ClientID)
131
+
assert.Equal(t, expectedApp.Name, existApp.Name)
132
+
assert.Equal(t, expectedApp.ClientID, existApp.ClientID)
133
133
assert.Equal(t, expectedApp.ConfidentialClient, existApp.ConfidentialClient)
134
134
assert.Len(t, expectedApp.ClientID, 36)
135
135
assert.Empty(t, expectedApp.ClientSecret)
136
136
assert.Len(t, expectedApp.RedirectURIs, 1)
137
-
assert.EqualValues(t, expectedApp.RedirectURIs[0], existApp.RedirectURIs[0])
137
+
assert.Equal(t, expectedApp.RedirectURIs[0], existApp.RedirectURIs[0])
138
138
unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: expectedApp.ID, Name: expectedApp.Name})
139
139
}
140
140
···
168
168
expectedApp := app
169
169
170
170
assert.Len(t, expectedApp.RedirectURIs, 2)
171
-
assert.EqualValues(t, expectedApp.RedirectURIs[0], appBody.RedirectURIs[0])
172
-
assert.EqualValues(t, expectedApp.RedirectURIs[1], appBody.RedirectURIs[1])
171
+
assert.Equal(t, expectedApp.RedirectURIs[0], appBody.RedirectURIs[0])
172
+
assert.Equal(t, expectedApp.RedirectURIs[1], appBody.RedirectURIs[1])
173
173
assert.Equal(t, expectedApp.ConfidentialClient, appBody.ConfidentialClient)
174
174
unittest.AssertExistsAndLoadBean(t, &auth_model.OAuth2Application{ID: expectedApp.ID, Name: expectedApp.Name})
175
175
}
+1
-1
tests/integration/api_org_actions_test.go
+1
-1
tests/integration/api_org_actions_test.go
+3
-3
tests/integration/api_org_test.go
+3
-3
tests/integration/api_org_test.go
···
76
76
AddTokenAuth(token)
77
77
resp = MakeRequest(t, req, http.StatusOK)
78
78
DecodeJSON(t, resp, &apiOrg)
79
-
assert.EqualValues(t, org.UserName, apiOrg.Name)
79
+
assert.Equal(t, org.UserName, apiOrg.Name)
80
80
81
81
req = NewRequestf(t, "GET", "/api/v1/orgs/%s/repos", org.UserName).
82
82
AddTokenAuth(token)
···
96
96
var users []*api.User
97
97
DecodeJSON(t, resp, &users)
98
98
assert.Len(t, users, 1)
99
-
assert.EqualValues(t, "user1", users[0].UserName)
99
+
assert.Equal(t, "user1", users[0].UserName)
100
100
}
101
101
102
102
func TestAPIOrgRename(t *testing.T) {
···
238
238
DecodeJSON(t, resp, &data)
239
239
assert.True(t, data.Ok)
240
240
if assert.Len(t, data.Data, 1) {
241
-
assert.EqualValues(t, "Empty", data.Data[0].Name)
241
+
assert.Equal(t, "Empty", data.Data[0].Name)
242
242
}
243
243
}
244
244
+1
-1
tests/integration/api_packages_alt_test.go
+1
-1
tests/integration/api_packages_alt_test.go
···
579
579
assert.Equal(t, []int(nil), result.DirIndexes)
580
580
assert.Equal(t, []string{"hello"}, result.BaseNames)
581
581
assert.Equal(t, []string{"/usr/local/bin/"}, result.DirNames)
582
-
assert.Equal(t, "", result.DistTag)
582
+
assert.Empty(t, result.DistTag)
583
583
assert.Equal(t, "gitea-test-1.0.2-1.x86_64.rpm", result.AptIndexLegacyFileName)
584
584
assert.Equal(t, 7116, result.AptIndexLegacyFileSize)
585
585
assert.Equal(t, "9ea82dd62968719aea19c08cd2ced79a", result.MD5Sum)
+2
-2
tests/integration/api_packages_cargo_test.go
+2
-2
tests/integration/api_packages_cargo_test.go
···
403
403
404
404
flashCookie := session.GetCookie(gitea_context.CookieNameFlash)
405
405
assert.NotNil(t, flashCookie)
406
-
assert.EqualValues(t, "error%3DCannot%2Brebuild%252C%2Bno%2Bindex%2Bis%2Binitialized.", flashCookie.Value)
406
+
assert.Equal(t, "error%3DCannot%2Brebuild%252C%2Bno%2Bindex%2Bis%2Binitialized.", flashCookie.Value)
407
407
unittest.AssertExistsIf(t, false, &repo_model.Repository{OwnerID: user.ID, Name: cargo_service.IndexRepositoryName})
408
408
})
409
409
···
441
441
442
442
flashCookie := session.GetCookie(gitea_context.CookieNameFlash)
443
443
assert.NotNil(t, flashCookie)
444
-
assert.EqualValues(t, "success%3DThe%2BCargo%2Bindex%2Bwas%2Bsuccessfully%2Brebuild.", flashCookie.Value)
444
+
assert.Equal(t, "success%3DThe%2BCargo%2Bindex%2Bwas%2Bsuccessfully%2Brebuild.", flashCookie.Value)
445
445
})
446
446
})
447
447
}
+1
-1
tests/integration/api_packages_conan_test.go
+1
-1
tests/integration/api_packages_conan_test.go
+1
-1
tests/integration/api_packages_container_cleanup_sha256_test.go
+1
-1
tests/integration/api_packages_container_cleanup_sha256_test.go
+1
-1
tests/integration/api_packages_container_test.go
+1
-1
tests/integration/api_packages_container_test.go
···
392
392
assert.Equal(t, "application/vnd.docker.image.rootfs.diff.tar.gzip", pfd.Properties.GetByName(container_module.PropertyMediaType))
393
393
assert.Equal(t, blobDigest, pfd.Properties.GetByName(container_module.PropertyDigest))
394
394
default:
395
-
assert.FailNow(t, "unknown file: %s", pfd.File.Name)
395
+
assert.FailNow(t, "unknown file", "name: %s", pfd.File.Name)
396
396
}
397
397
}
398
398
+1
-1
tests/integration/api_packages_nuget_test.go
+1
-1
tests/integration/api_packages_nuget_test.go
+3
-3
tests/integration/api_packages_rpm_test.go
+3
-3
tests/integration/api_packages_rpm_test.go
···
317
317
var result Metadata
318
318
decodeGzipXML(t, resp, &result)
319
319
320
-
assert.EqualValues(t, 1, result.PackageCount)
320
+
assert.Equal(t, 1, result.PackageCount)
321
321
assert.Len(t, result.Packages, 1)
322
322
p := result.Packages[0]
323
323
assert.Equal(t, "rpm", p.Type)
···
366
366
var result Filelists
367
367
decodeGzipXML(t, resp, &result)
368
368
369
-
assert.EqualValues(t, 1, result.PackageCount)
369
+
assert.Equal(t, 1, result.PackageCount)
370
370
assert.Len(t, result.Packages, 1)
371
371
p := result.Packages[0]
372
372
assert.NotEmpty(t, p.Pkgid)
···
403
403
var result Other
404
404
decodeGzipXML(t, resp, &result)
405
405
406
-
assert.EqualValues(t, 1, result.PackageCount)
406
+
assert.Equal(t, 1, result.PackageCount)
407
407
assert.Len(t, result.Packages, 1)
408
408
p := result.Packages[0]
409
409
assert.NotEmpty(t, p.Pkgid)
+1
-1
tests/integration/api_packages_test.go
+1
-1
tests/integration/api_packages_test.go
···
115
115
var ap2 *api.Package
116
116
DecodeJSON(t, resp, &ap2)
117
117
assert.NotNil(t, ap2.Repository)
118
-
assert.EqualValues(t, repo.ID, ap2.Repository.ID)
118
+
assert.Equal(t, repo.ID, ap2.Repository.ID)
119
119
120
120
// link to repository without write access, should fail
121
121
req = NewRequest(t, "POST", fmt.Sprintf("/api/v1/packages/%s/generic/%s/-/link/%s", user.Name, packageName, "repo3")).AddTokenAuth(tokenWritePackage)
+25
-25
tests/integration/api_pull_review_test.go
+25
-25
tests/integration/api_pull_review_test.go
···
85
85
resp := MakeRequest(t, req, http.StatusOK)
86
86
DecodeJSON(t, resp, &review)
87
87
require.EqualValues(t, string(event), review.State)
88
-
require.EqualValues(t, 0, review.CodeCommentsCount)
88
+
require.Equal(t, 0, review.CodeCommentsCount)
89
89
}
90
90
91
91
{
···
94
94
resp := MakeRequest(t, req, http.StatusOK)
95
95
var getReview api.PullReview
96
96
DecodeJSON(t, resp, &getReview)
97
-
require.EqualValues(t, getReview, review)
97
+
require.Equal(t, getReview, review)
98
98
}
99
99
requireReviewCount(2)
100
100
···
109
109
}).AddTokenAuth(token)
110
110
resp := MakeRequest(t, req, http.StatusOK)
111
111
DecodeJSON(t, resp, &reviewComment)
112
-
assert.EqualValues(t, review.ID, reviewComment.ReviewID)
113
-
assert.EqualValues(t, newCommentBody, reviewComment.Body)
112
+
assert.Equal(t, review.ID, reviewComment.ReviewID)
113
+
assert.Equal(t, newCommentBody, reviewComment.Body)
114
114
assert.EqualValues(t, reviewLine, reviewComment.OldLineNum)
115
115
assert.EqualValues(t, 0, reviewComment.LineNum)
116
-
assert.EqualValues(t, path, reviewComment.Path)
116
+
assert.Equal(t, path, reviewComment.Path)
117
117
}
118
118
119
119
{
···
123
123
124
124
var comment api.PullReviewComment
125
125
DecodeJSON(t, resp, &comment)
126
-
assert.EqualValues(t, reviewComment, comment)
126
+
assert.Equal(t, reviewComment, comment)
127
127
}
128
128
129
129
{
···
167
167
return
168
168
}
169
169
for _, r := range reviews {
170
-
assert.EqualValues(t, pullIssue.HTMLURL(), r.HTMLPullURL)
170
+
assert.Equal(t, pullIssue.HTMLURL(), r.HTMLPullURL)
171
171
}
172
172
assert.EqualValues(t, 8, reviews[3].ID)
173
173
assert.EqualValues(t, "APPROVED", reviews[3].State)
174
-
assert.EqualValues(t, 0, reviews[3].CodeCommentsCount)
174
+
assert.Equal(t, 0, reviews[3].CodeCommentsCount)
175
175
assert.True(t, reviews[3].Stale)
176
176
assert.False(t, reviews[3].Official)
177
177
178
178
assert.EqualValues(t, 10, reviews[5].ID)
179
179
assert.EqualValues(t, "REQUEST_CHANGES", reviews[5].State)
180
-
assert.EqualValues(t, 1, reviews[5].CodeCommentsCount)
180
+
assert.Equal(t, 1, reviews[5].CodeCommentsCount)
181
181
assert.EqualValues(t, -1, reviews[5].Reviewer.ID) // ghost user
182
182
assert.False(t, reviews[5].Stale)
183
183
assert.True(t, reviews[5].Official)
···
188
188
resp = MakeRequest(t, req, http.StatusOK)
189
189
var review api.PullReview
190
190
DecodeJSON(t, resp, &review)
191
-
assert.EqualValues(t, *reviews[3], review)
191
+
assert.Equal(t, *reviews[3], review)
192
192
193
193
req = NewRequestf(t, "GET", "/api/v1/repos/%s/%s/pulls/%d/reviews/%d", repo.OwnerName, repo.Name, pullIssue.Index, reviews[5].ID).
194
194
AddTokenAuth(token)
195
195
resp = MakeRequest(t, req, http.StatusOK)
196
196
DecodeJSON(t, resp, &review)
197
-
assert.EqualValues(t, *reviews[5], review)
197
+
assert.Equal(t, *reviews[5], review)
198
198
199
199
// test GetPullReviewComments
200
200
comment := unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: 7})
···
204
204
var reviewComments []*api.PullReviewComment
205
205
DecodeJSON(t, resp, &reviewComments)
206
206
assert.Len(t, reviewComments, 1)
207
-
assert.EqualValues(t, "Ghost", reviewComments[0].Poster.UserName)
208
-
assert.EqualValues(t, "a review from a deleted user", reviewComments[0].Body)
209
-
assert.EqualValues(t, comment.ID, reviewComments[0].ID)
207
+
assert.Equal(t, "Ghost", reviewComments[0].Poster.UserName)
208
+
assert.Equal(t, "a review from a deleted user", reviewComments[0].Body)
209
+
assert.Equal(t, comment.ID, reviewComments[0].ID)
210
210
assert.EqualValues(t, comment.UpdatedUnix, reviewComments[0].Updated.Unix())
211
-
assert.EqualValues(t, comment.HTMLURL(db.DefaultContext), reviewComments[0].HTMLURL)
211
+
assert.Equal(t, comment.HTMLURL(db.DefaultContext), reviewComments[0].HTMLURL)
212
212
213
213
// test CreatePullReview
214
214
req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews", repo.OwnerName, repo.Name, pullIssue.Index), &api.CreatePullReviewOptions{
···
237
237
DecodeJSON(t, resp, &review)
238
238
assert.EqualValues(t, 6, review.ID)
239
239
assert.EqualValues(t, "PENDING", review.State)
240
-
assert.EqualValues(t, 3, review.CodeCommentsCount)
240
+
assert.Equal(t, 3, review.CodeCommentsCount)
241
241
242
242
// test SubmitPullReview
243
243
req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews/%d", repo.OwnerName, repo.Name, pullIssue.Index, review.ID), &api.SubmitPullReviewOptions{
···
248
248
DecodeJSON(t, resp, &review)
249
249
assert.EqualValues(t, 6, review.ID)
250
250
assert.EqualValues(t, "APPROVED", review.State)
251
-
assert.EqualValues(t, 3, review.CodeCommentsCount)
251
+
assert.Equal(t, 3, review.CodeCommentsCount)
252
252
253
253
// test dismiss review
254
254
req = NewRequestWithJSON(t, http.MethodPost, fmt.Sprintf("/api/v1/repos/%s/%s/pulls/%d/reviews/%d/dismissals", repo.OwnerName, repo.Name, pullIssue.Index, review.ID), &api.DismissPullReviewOptions{
···
275
275
resp = MakeRequest(t, req, http.StatusOK)
276
276
DecodeJSON(t, resp, &review)
277
277
assert.EqualValues(t, "COMMENT", review.State)
278
-
assert.EqualValues(t, 0, review.CodeCommentsCount)
278
+
assert.Equal(t, 0, review.CodeCommentsCount)
279
279
req = NewRequestf(t, http.MethodDelete, "/api/v1/repos/%s/%s/pulls/%d/reviews/%d", repo.OwnerName, repo.Name, pullIssue.Index, review.ID).
280
280
AddTokenAuth(token)
281
281
MakeRequest(t, req, http.StatusNoContent)
···
303
303
resp = MakeRequest(t, req, http.StatusOK)
304
304
DecodeJSON(t, resp, &commentReview)
305
305
assert.EqualValues(t, "COMMENT", commentReview.State)
306
-
assert.EqualValues(t, 2, commentReview.CodeCommentsCount)
306
+
assert.Equal(t, 2, commentReview.CodeCommentsCount)
307
307
assert.Empty(t, commentReview.Body)
308
308
assert.False(t, commentReview.Dismissed)
309
309
···
318
318
resp = MakeRequest(t, req, http.StatusOK)
319
319
DecodeJSON(t, resp, &commentReview)
320
320
assert.EqualValues(t, "COMMENT", commentReview.State)
321
-
assert.EqualValues(t, 0, commentReview.CodeCommentsCount)
322
-
assert.EqualValues(t, commentBody, commentReview.Body)
321
+
assert.Equal(t, 0, commentReview.CodeCommentsCount)
322
+
assert.Equal(t, commentBody, commentReview.Body)
323
323
assert.False(t, commentReview.Dismissed)
324
324
325
325
// test CreatePullReview Comment without body and no comments
···
331
331
resp = MakeRequest(t, req, http.StatusUnprocessableEntity)
332
332
errMap := make(map[string]any)
333
333
json.Unmarshal(resp.Body.Bytes(), &errMap)
334
-
assert.EqualValues(t, "review event COMMENT requires a body or a comment", errMap["message"].(string))
334
+
assert.Equal(t, "review event COMMENT requires a body or a comment", errMap["message"].(string))
335
335
336
336
// test get review requests
337
337
// to make it simple, use same api with get review
···
345
345
DecodeJSON(t, resp, &reviews)
346
346
assert.EqualValues(t, 11, reviews[0].ID)
347
347
assert.EqualValues(t, "REQUEST_REVIEW", reviews[0].State)
348
-
assert.EqualValues(t, 0, reviews[0].CodeCommentsCount)
348
+
assert.Equal(t, 0, reviews[0].CodeCommentsCount)
349
349
assert.False(t, reviews[0].Stale)
350
350
assert.True(t, reviews[0].Official)
351
-
assert.EqualValues(t, "test_team", reviews[0].ReviewerTeam.Name)
351
+
assert.Equal(t, "test_team", reviews[0].ReviewerTeam.Name)
352
352
353
353
assert.EqualValues(t, 12, reviews[1].ID)
354
354
assert.EqualValues(t, "REQUEST_REVIEW", reviews[1].State)
355
-
assert.EqualValues(t, 0, reviews[0].CodeCommentsCount)
355
+
assert.Equal(t, 0, reviews[0].CodeCommentsCount)
356
356
assert.False(t, reviews[1].Stale)
357
357
assert.True(t, reviews[1].Official)
358
358
assert.EqualValues(t, 1, reviews[1].Reviewer.ID)
+10
-10
tests/integration/api_pull_test.go
+10
-10
tests/integration/api_pull_test.go
···
56
56
if assert.Len(t, files, 1) {
57
57
assert.Equal(t, "File-WoW", files[0].Filename)
58
58
assert.Empty(t, files[0].PreviousFilename)
59
-
assert.EqualValues(t, 1, files[0].Additions)
60
-
assert.EqualValues(t, 1, files[0].Changes)
61
-
assert.EqualValues(t, 0, files[0].Deletions)
59
+
assert.Equal(t, 1, files[0].Additions)
60
+
assert.Equal(t, 1, files[0].Changes)
61
+
assert.Equal(t, 0, files[0].Deletions)
62
62
assert.Equal(t, "added", files[0].Status)
63
63
}
64
64
}))
···
177
177
DecodeJSON(t, res, pull)
178
178
179
179
assert.NotNil(t, pull.Milestone)
180
-
assert.EqualValues(t, opts.Milestone, pull.Milestone.ID)
180
+
assert.Equal(t, opts.Milestone, pull.Milestone.ID)
181
181
if assert.Len(t, pull.Assignees, 1) {
182
-
assert.EqualValues(t, opts.Assignees[0], owner10.Name)
182
+
assert.Equal(t, opts.Assignees[0], owner10.Name)
183
183
}
184
184
assert.NotNil(t, pull.Labels)
185
-
assert.EqualValues(t, opts.Labels[0], pull.Labels[0].ID)
185
+
assert.Equal(t, opts.Labels[0], pull.Labels[0].ID)
186
186
}
187
187
188
188
func TestAPICreatePullWithFieldsFailure(t *testing.T) {
···
236
236
apiPull := new(api.PullRequest)
237
237
resp := MakeRequest(t, req, http.StatusCreated)
238
238
DecodeJSON(t, resp, apiPull)
239
-
assert.EqualValues(t, "master", apiPull.Base.Name)
239
+
assert.Equal(t, "master", apiPull.Base.Name)
240
240
241
241
newTitle := "edit a this pr"
242
242
newBody := "edited body"
···
248
248
}).AddTokenAuth(token)
249
249
resp = MakeRequest(t, req, http.StatusCreated)
250
250
DecodeJSON(t, resp, apiPull)
251
-
assert.EqualValues(t, "feature/1", apiPull.Base.Name)
251
+
assert.Equal(t, "feature/1", apiPull.Base.Name)
252
252
// check comment history
253
253
pull := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: apiPull.ID})
254
254
err := pull.LoadIssue(db.DefaultContext)
···
264
264
apiPullIdempotent := new(api.PullRequest)
265
265
resp = MakeRequest(t, req, http.StatusCreated)
266
266
DecodeJSON(t, resp, apiPullIdempotent)
267
-
assert.EqualValues(t, apiPull.State, apiPullIdempotent.State)
267
+
assert.Equal(t, apiPull.State, apiPullIdempotent.State)
268
268
269
269
req = NewRequestWithJSON(t, http.MethodPatch, urlStr, &api.EditPullRequestOption{
270
270
Base: "not-exist",
···
340
340
var bodyResp userResponse
341
341
DecodeJSON(t, resp, &bodyResp)
342
342
343
-
assert.EqualValues(t, "insufficient permission to delete head branch", bodyResp.Message)
343
+
assert.Equal(t, "insufficient permission to delete head branch", bodyResp.Message)
344
344
345
345
// Check that the branch still exist.
346
346
req = NewRequest(t, "GET", "/api/v1/repos/user2/repo1/branches/base-pr").AddTokenAuth(token)
+6
-6
tests/integration/api_push_mirror_test.go
+6
-6
tests/integration/api_push_mirror_test.go
···
123
123
if testCase.message != "" {
124
124
err := api.APIError{}
125
125
DecodeJSON(t, resp, &err)
126
-
assert.EqualValues(t, testCase.message, err.Message)
126
+
assert.Equal(t, testCase.message, err.Message)
127
127
}
128
128
129
129
req = NewRequest(t, "GET", urlStr).AddTokenAuth(token)
···
132
132
DecodeJSON(t, resp, &pushMirrors)
133
133
if assert.Len(t, pushMirrors, testCase.mirrorCount) && testCase.mirrorCount > 0 {
134
134
pushMirror := pushMirrors[0]
135
-
assert.EqualValues(t, remoteAddress, pushMirror.RemoteAddress)
135
+
assert.Equal(t, remoteAddress, pushMirror.RemoteAddress)
136
136
137
137
repo_model.DeletePushMirrors = deletePushMirrors
138
138
req = NewRequest(t, "DELETE", fmt.Sprintf("%s/%s", urlStr, pushMirror.RemoteName)).AddTokenAuth(token)
···
182
182
183
183
var apiError api.APIError
184
184
DecodeJSON(t, resp, &apiError)
185
-
assert.EqualValues(t, "'use_ssh' is mutually exclusive with 'remote_username' and 'remote_passoword'", apiError.Message)
185
+
assert.Equal(t, "'use_ssh' is mutually exclusive with 'remote_username' and 'remote_passoword'", apiError.Message)
186
186
})
187
187
188
188
t.Run("SSH not available", func(t *testing.T) {
···
198
198
199
199
var apiError api.APIError
200
200
DecodeJSON(t, resp, &apiError)
201
-
assert.EqualValues(t, "SSH authentication not available.", apiError.Message)
201
+
assert.Equal(t, "SSH authentication not available.", apiError.Message)
202
202
})
203
203
204
204
t.Run("Normal", func(t *testing.T) {
···
228
228
var pushMirrors []*api.PushMirror
229
229
DecodeJSON(t, resp, &pushMirrors)
230
230
assert.Len(t, pushMirrors, 1)
231
-
assert.EqualValues(t, publickey, pushMirrors[0].PublicKey)
231
+
assert.Equal(t, publickey, pushMirrors[0].PublicKey)
232
232
})
233
233
234
234
t.Run("Add deploy key", func(t *testing.T) {
···
262
262
DecodeJSON(t, resp, &commitList)
263
263
264
264
assert.Len(t, commitList, 1)
265
-
assert.EqualValues(t, sha, commitList[0].SHA)
265
+
assert.Equal(t, sha, commitList[0].SHA)
266
266
267
267
assert.Eventually(t, func() bool {
268
268
req := NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/commits?limit=1", srcRepo.FullName())).AddTokenAuth(token)
+6
-6
tests/integration/api_quota_management_test.go
+6
-6
tests/integration/api_quota_management_test.go
···
122
122
require.NoError(t, err)
123
123
assert.NotNil(t, rule)
124
124
assert.EqualValues(t, -1, rule.Limit)
125
-
assert.EqualValues(t, quota_model.LimitSubjects{quota_model.LimitSubjectSizeAll}, rule.Subjects)
125
+
assert.Equal(t, quota_model.LimitSubjects{quota_model.LimitSubjectSizeAll}, rule.Subjects)
126
126
127
127
rule, err = quota_model.GetRuleByName(db.DefaultContext, "deny-git-lfs")
128
128
require.NoError(t, err)
129
129
assert.NotNil(t, rule)
130
130
assert.EqualValues(t, 0, rule.Limit)
131
-
assert.EqualValues(t, quota_model.LimitSubjects{quota_model.LimitSubjectSizeGitLFS}, rule.Subjects)
131
+
assert.Equal(t, quota_model.LimitSubjects{quota_model.LimitSubjectSizeGitLFS}, rule.Subjects)
132
132
133
133
// Verify that the new rule was also created
134
134
rule, err = quota_model.GetRuleByName(db.DefaultContext, "new-rule")
135
135
require.NoError(t, err)
136
136
assert.NotNil(t, rule)
137
137
assert.EqualValues(t, 0, rule.Limit)
138
-
assert.EqualValues(t, quota_model.LimitSubjects{quota_model.LimitSubjectSizeAssetsAll}, rule.Subjects)
138
+
assert.Equal(t, quota_model.LimitSubjects{quota_model.LimitSubjectSizeAssetsAll}, rule.Subjects)
139
139
140
140
t.Run("invalid rule spec", func(t *testing.T) {
141
141
defer tests.PrintCurrentTest(t)()
···
176
176
var q api.QuotaInfo
177
177
DecodeJSON(t, resp, &q)
178
178
179
-
assert.EqualValues(t, api.QuotaUsed{}, q.Used)
179
+
assert.Equal(t, api.QuotaUsed{}, q.Used)
180
180
assert.Empty(t, q.Groups)
181
181
})
182
182
···
189
189
var q api.QuotaInfo
190
190
DecodeJSON(t, resp, &q)
191
191
192
-
assert.EqualValues(t, api.QuotaUsed{}, q.Used)
192
+
assert.Equal(t, api.QuotaUsed{}, q.Used)
193
193
assert.Empty(t, q.Groups)
194
194
195
195
t.Run("#/user/quota/artifacts", func(t *testing.T) {
···
295
295
296
296
assert.Equal(t, "deny-all", q.Name)
297
297
assert.EqualValues(t, 0, q.Limit)
298
-
assert.EqualValues(t, []string{"size:all"}, q.Subjects)
298
+
assert.Equal(t, []string{"size:all"}, q.Subjects)
299
299
300
300
rule, err := quota_model.GetRuleByName(db.DefaultContext, "deny-all")
301
301
require.NoError(t, err)
+1
-1
tests/integration/api_quota_use_test.go
+1
-1
tests/integration/api_quota_use_test.go
+9
-9
tests/integration/api_releases_test.go
+9
-9
tests/integration/api_releases_test.go
···
99
99
Title: newRelease.Title,
100
100
}
101
101
unittest.AssertExistsAndLoadBean(t, rel)
102
-
assert.EqualValues(t, newRelease.Note, rel.Note)
102
+
assert.Equal(t, newRelease.Note, rel.Note)
103
103
104
104
return &newRelease
105
105
}
···
157
157
Title: newRelease.Title,
158
158
}
159
159
unittest.AssertExistsAndLoadBean(t, rel)
160
-
assert.EqualValues(t, rel.Note, newRelease.Note)
160
+
assert.Equal(t, rel.Note, newRelease.Note)
161
161
assert.True(t, newRelease.HideArchiveLinks)
162
162
}
163
163
···
336
336
var attachment *api.Attachment
337
337
DecodeJSON(t, resp, &attachment)
338
338
339
-
assert.EqualValues(t, filename, attachment.Name)
339
+
assert.Equal(t, filename, attachment.Name)
340
340
assert.EqualValues(t, 104, attachment.Size)
341
341
342
342
req = NewRequestWithBody(t, http.MethodPost, assetURL+"?name=test-asset", bytes.NewReader(body.Bytes())).
···
347
347
var attachment2 *api.Attachment
348
348
DecodeJSON(t, resp, &attachment2)
349
349
350
-
assert.EqualValues(t, "test-asset", attachment2.Name)
350
+
assert.Equal(t, "test-asset", attachment2.Name)
351
351
assert.EqualValues(t, 104, attachment2.Size)
352
352
})
353
353
···
365
365
var attachment *api.Attachment
366
366
DecodeJSON(t, resp, &attachment)
367
367
368
-
assert.EqualValues(t, "stream.bin", attachment.Name)
368
+
assert.Equal(t, "stream.bin", attachment.Name)
369
369
assert.EqualValues(t, 104, attachment.Size)
370
-
assert.EqualValues(t, "attachment", attachment.Type)
370
+
assert.Equal(t, "attachment", attachment.Type)
371
371
})
372
372
}
373
373
···
424
424
var attachment *api.Attachment
425
425
DecodeJSON(t, resp, &attachment)
426
426
427
-
assert.EqualValues(t, "test-asset", attachment.Name)
427
+
assert.Equal(t, "test-asset", attachment.Name)
428
428
assert.EqualValues(t, 0, attachment.Size)
429
-
assert.EqualValues(t, "https://forgejo.org/", attachment.DownloadURL)
430
-
assert.EqualValues(t, "external", attachment.Type)
429
+
assert.Equal(t, "https://forgejo.org/", attachment.DownloadURL)
430
+
assert.Equal(t, "external", attachment.Type)
431
431
}
432
432
433
433
func TestAPIDuplicateAssetRelease(t *testing.T) {
+1
-1
tests/integration/api_repo_actions_test.go
+1
-1
tests/integration/api_repo_actions_test.go
+5
-5
tests/integration/api_repo_archive_test.go
+5
-5
tests/integration/api_repo_archive_test.go
···
34
34
bs, err := io.ReadAll(resp.Body)
35
35
require.NoError(t, err)
36
36
assert.Len(t, bs, 320)
37
-
assert.EqualValues(t, "application/zip", resp.Header().Get("Content-Type"))
37
+
assert.Equal(t, "application/zip", resp.Header().Get("Content-Type"))
38
38
39
39
link, _ = url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/archive/master.tar.gz", user2.Name, repo.Name))
40
40
resp = MakeRequest(t, NewRequest(t, "GET", link.String()).AddTokenAuth(token), http.StatusOK)
41
41
bs, err = io.ReadAll(resp.Body)
42
42
require.NoError(t, err)
43
43
assert.Len(t, bs, 266)
44
-
assert.EqualValues(t, "application/gzip", resp.Header().Get("Content-Type"))
44
+
assert.Equal(t, "application/gzip", resp.Header().Get("Content-Type"))
45
45
46
46
// Must return a link to a commit ID as the "immutable" archive link
47
47
linkHeaderRe := regexp.MustCompile(`<(?P<url>https?://.*/api/v1/repos/user2/repo1/archive/[a-f0-9]+\.tar\.gz.*)>; rel="immutable"`)
···
51
51
bs2, err := io.ReadAll(resp.Body)
52
52
require.NoError(t, err)
53
53
// The locked URL should give the same bytes as the non-locked one
54
-
assert.EqualValues(t, bs, bs2)
54
+
assert.Equal(t, bs, bs2)
55
55
56
56
link, _ = url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/archive/master.bundle", user2.Name, repo.Name))
57
57
resp = MakeRequest(t, NewRequest(t, "GET", link.String()).AddTokenAuth(token), http.StatusOK)
58
58
bs, err = io.ReadAll(resp.Body)
59
59
require.NoError(t, err)
60
60
assert.Len(t, bs, 382)
61
-
assert.EqualValues(t, "application/octet-stream", resp.Header().Get("Content-Type"))
61
+
assert.Equal(t, "application/octet-stream", resp.Header().Get("Content-Type"))
62
62
63
63
link, _ = url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/archive/master", user2.Name, repo.Name))
64
64
MakeRequest(t, NewRequest(t, "GET", link.String()).AddTokenAuth(token), http.StatusBadRequest)
···
92
92
bs2, err := io.ReadAll(resp.Body)
93
93
require.NoError(t, err)
94
94
// The locked URL should give the same bytes as the non-locked one
95
-
assert.EqualValues(t, bs, bs2)
95
+
assert.Equal(t, bs, bs2)
96
96
97
97
link, _ = url.Parse(fmt.Sprintf("/api/v1/repos/%s/%s/bundle/master", user2.Name, repo.Name))
98
98
resp = MakeRequest(t, NewRequest(t, "GET", link.String()).AddTokenAuth(token), http.StatusOK)
+13
-13
tests/integration/api_repo_branch_test.go
+13
-13
tests/integration/api_repo_branch_test.go
···
43
43
var branches []*api.Branch
44
44
require.NoError(t, json.Unmarshal(bs, &branches))
45
45
assert.Len(t, branches, 2)
46
-
assert.EqualValues(t, "test_branch", branches[0].Name)
47
-
assert.EqualValues(t, "master", branches[1].Name)
46
+
assert.Equal(t, "test_branch", branches[0].Name)
47
+
assert.Equal(t, "master", branches[1].Name)
48
48
49
49
link2, _ := url.Parse(fmt.Sprintf("/api/v1/repos/org3/%s/branches/test_branch", repo3.Name))
50
50
MakeRequest(t, NewRequest(t, "GET", link2.String()).AddTokenAuth(publicOnlyToken), http.StatusForbidden)
···
54
54
require.NoError(t, err)
55
55
var branch api.Branch
56
56
require.NoError(t, json.Unmarshal(bs, &branch))
57
-
assert.EqualValues(t, "test_branch", branch.Name)
57
+
assert.Equal(t, "test_branch", branch.Name)
58
58
59
59
MakeRequest(t, NewRequest(t, "POST", link.String()).AddTokenAuth(publicOnlyToken), http.StatusForbidden)
60
60
···
66
66
require.NoError(t, err)
67
67
var branch2 api.Branch
68
68
require.NoError(t, json.Unmarshal(bs, &branch2))
69
-
assert.EqualValues(t, "test_branch2", branch2.Name)
70
-
assert.EqualValues(t, branch.Commit.ID, branch2.Commit.ID)
69
+
assert.Equal(t, "test_branch2", branch2.Name)
70
+
assert.Equal(t, branch.Commit.ID, branch2.Commit.ID)
71
71
72
72
resp = MakeRequest(t, NewRequest(t, "GET", link.String()).AddTokenAuth(token), http.StatusOK)
73
73
bs, err = io.ReadAll(resp.Body)
···
76
76
branches = []*api.Branch{}
77
77
require.NoError(t, json.Unmarshal(bs, &branches))
78
78
assert.Len(t, branches, 3)
79
-
assert.EqualValues(t, "test_branch", branches[0].Name)
80
-
assert.EqualValues(t, "test_branch2", branches[1].Name)
81
-
assert.EqualValues(t, "master", branches[2].Name)
79
+
assert.Equal(t, "test_branch", branches[0].Name)
80
+
assert.Equal(t, "test_branch2", branches[1].Name)
81
+
assert.Equal(t, "master", branches[2].Name)
82
82
83
83
link3, _ := url.Parse(fmt.Sprintf("/api/v1/repos/org3/%s/branches/test_branch2", repo3.Name))
84
84
MakeRequest(t, NewRequest(t, "DELETE", link3.String()), http.StatusNotFound)
···
105
105
var branches []*api.Branch
106
106
require.NoError(t, json.Unmarshal(bs, &branches))
107
107
assert.Len(t, branches, 2)
108
-
assert.EqualValues(t, "test_branch", branches[0].Name)
109
-
assert.EqualValues(t, "master", branches[1].Name)
108
+
assert.Equal(t, "test_branch", branches[0].Name)
109
+
assert.Equal(t, "master", branches[1].Name)
110
110
111
111
link2, _ := url.Parse(fmt.Sprintf("/api/v1/repos/org3/%s/branches/test_branch", repo5.Name))
112
112
resp = MakeRequest(t, NewRequest(t, "GET", link2.String()).AddTokenAuth(token), http.StatusOK)
···
114
114
require.NoError(t, err)
115
115
var branch api.Branch
116
116
require.NoError(t, json.Unmarshal(bs, &branch))
117
-
assert.EqualValues(t, "test_branch", branch.Name)
117
+
assert.Equal(t, "test_branch", branch.Name)
118
118
119
119
req := NewRequest(t, "POST", link.String()).AddTokenAuth(token)
120
120
req.Header.Add("Content-Type", "application/json")
···
122
122
resp = MakeRequest(t, req, http.StatusForbidden)
123
123
bs, err = io.ReadAll(resp.Body)
124
124
require.NoError(t, err)
125
-
assert.EqualValues(t, "{\"message\":\"Git Repository is a mirror.\",\"url\":\""+setting.AppURL+"api/swagger\"}\n", string(bs))
125
+
assert.Equal(t, "{\"message\":\"Git Repository is a mirror.\",\"url\":\""+setting.AppURL+"api/swagger\"}\n", string(bs))
126
126
127
127
resp = MakeRequest(t, NewRequest(t, "DELETE", link2.String()).AddTokenAuth(token), http.StatusForbidden)
128
128
bs, err = io.ReadAll(resp.Body)
129
129
require.NoError(t, err)
130
-
assert.EqualValues(t, "{\"message\":\"Git Repository is a mirror.\",\"url\":\""+setting.AppURL+"api/swagger\"}\n", string(bs))
130
+
assert.Equal(t, "{\"message\":\"Git Repository is a mirror.\",\"url\":\""+setting.AppURL+"api/swagger\"}\n", string(bs))
131
131
}
+23
-23
tests/integration/api_repo_file_create_test.go
+23
-23
tests/integration/api_repo_file_create_test.go
···
177
177
expectedFileResponse := getExpectedFileResponseForCreate("user2/repo1", commitID, treePath, latestCommit.ID.String())
178
178
var fileResponse api.FileResponse
179
179
DecodeJSON(t, resp, &fileResponse)
180
-
assert.EqualValues(t, expectedFileResponse.Content, fileResponse.Content)
181
-
assert.EqualValues(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
182
-
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
183
-
assert.EqualValues(t, expectedFileResponse.Commit.Author.Email, fileResponse.Commit.Author.Email)
184
-
assert.EqualValues(t, expectedFileResponse.Commit.Author.Name, fileResponse.Commit.Author.Name)
185
-
assert.EqualValues(t, expectedFileResponse.Commit.Author.Date, fileResponse.Commit.Author.Date)
186
-
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Email, fileResponse.Commit.Committer.Email)
187
-
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Name, fileResponse.Commit.Committer.Name)
188
-
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Date, fileResponse.Commit.Committer.Date)
180
+
assert.Equal(t, expectedFileResponse.Content, fileResponse.Content)
181
+
assert.Equal(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
182
+
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
183
+
assert.Equal(t, expectedFileResponse.Commit.Author.Email, fileResponse.Commit.Author.Email)
184
+
assert.Equal(t, expectedFileResponse.Commit.Author.Name, fileResponse.Commit.Author.Name)
185
+
assert.Equal(t, expectedFileResponse.Commit.Author.Date, fileResponse.Commit.Author.Date)
186
+
assert.Equal(t, expectedFileResponse.Commit.Committer.Email, fileResponse.Commit.Committer.Email)
187
+
assert.Equal(t, expectedFileResponse.Commit.Committer.Name, fileResponse.Commit.Committer.Name)
188
+
assert.Equal(t, expectedFileResponse.Commit.Committer.Date, fileResponse.Commit.Committer.Date)
189
189
gitRepo.Close()
190
190
}
191
191
···
203
203
expectedSHA := "a635aa942442ddfdba07468cf9661c08fbdf0ebf"
204
204
expectedHTMLURL := fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/new_branch/new/file%d.txt", fileID)
205
205
expectedDownloadURL := fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/new_branch/new/file%d.txt", fileID)
206
-
assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA)
207
-
assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
208
-
assert.EqualValues(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
209
-
assert.EqualValues(t, createFileOptions.Message+"\n", fileResponse.Commit.Message)
206
+
assert.Equal(t, expectedSHA, fileResponse.Content.SHA)
207
+
assert.Equal(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
208
+
assert.Equal(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
209
+
assert.Equal(t, createFileOptions.Message+"\n", fileResponse.Commit.Message)
210
210
211
211
// Test creating a file without a message
212
212
createFileOptions = getCreateFileOptions()
···
218
218
resp = MakeRequest(t, req, http.StatusCreated)
219
219
DecodeJSON(t, resp, &fileResponse)
220
220
expectedMessage := "Add " + treePath + "\n"
221
-
assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message)
221
+
assert.Equal(t, expectedMessage, fileResponse.Commit.Message)
222
222
223
223
// Test trying to create a file that already exists, should fail
224
224
createFileOptions = getCreateFileOptions()
···
296
296
latestCommit, _ := gitRepo.GetCommitByPath(treePath)
297
297
expectedFileResponse := getExpectedFileResponseForCreate("user2/"+reponame, commitID, treePath, latestCommit.ID.String())
298
298
DecodeJSON(t, resp, &fileResponse)
299
-
assert.EqualValues(t, expectedFileResponse.Content, fileResponse.Content)
300
-
assert.EqualValues(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
301
-
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
302
-
assert.EqualValues(t, expectedFileResponse.Commit.Author.Email, fileResponse.Commit.Author.Email)
303
-
assert.EqualValues(t, expectedFileResponse.Commit.Author.Name, fileResponse.Commit.Author.Name)
304
-
assert.EqualValues(t, expectedFileResponse.Commit.Author.Date, fileResponse.Commit.Author.Date)
305
-
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Email, fileResponse.Commit.Committer.Email)
306
-
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Name, fileResponse.Commit.Committer.Name)
307
-
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Date, fileResponse.Commit.Committer.Date)
299
+
assert.Equal(t, expectedFileResponse.Content, fileResponse.Content)
300
+
assert.Equal(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
301
+
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
302
+
assert.Equal(t, expectedFileResponse.Commit.Author.Email, fileResponse.Commit.Author.Email)
303
+
assert.Equal(t, expectedFileResponse.Commit.Author.Name, fileResponse.Commit.Author.Name)
304
+
assert.Equal(t, expectedFileResponse.Commit.Author.Date, fileResponse.Commit.Author.Date)
305
+
assert.Equal(t, expectedFileResponse.Commit.Committer.Email, fileResponse.Commit.Committer.Email)
306
+
assert.Equal(t, expectedFileResponse.Commit.Committer.Name, fileResponse.Commit.Committer.Name)
307
+
assert.Equal(t, expectedFileResponse.Commit.Committer.Date, fileResponse.Commit.Committer.Date)
308
308
gitRepo.Close()
309
309
})
310
310
})
+2
-2
tests/integration/api_repo_file_delete_test.go
+2
-2
tests/integration/api_repo_file_delete_test.go
···
87
87
DecodeJSON(t, resp, &fileResponse)
88
88
assert.NotNil(t, fileResponse)
89
89
assert.Nil(t, fileResponse.Content)
90
-
assert.EqualValues(t, deleteFileOptions.Message+"\n", fileResponse.Commit.Message)
90
+
assert.Equal(t, deleteFileOptions.Message+"\n", fileResponse.Commit.Message)
91
91
92
92
// Test deleting file without a message
93
93
fileID++
···
100
100
resp = MakeRequest(t, req, http.StatusOK)
101
101
DecodeJSON(t, resp, &fileResponse)
102
102
expectedMessage := "Delete " + treePath + "\n"
103
-
assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message)
103
+
assert.Equal(t, expectedMessage, fileResponse.Commit.Message)
104
104
105
105
// Test deleting a file with the wrong SHA
106
106
fileID++
+13
-13
tests/integration/api_repo_file_update_test.go
+13
-13
tests/integration/api_repo_file_update_test.go
···
140
140
expectedFileResponse := getExpectedFileResponseForUpdate(commitID, treePath, lasCommit.ID.String())
141
141
var fileResponse api.FileResponse
142
142
DecodeJSON(t, resp, &fileResponse)
143
-
assert.EqualValues(t, expectedFileResponse.Content, fileResponse.Content)
144
-
assert.EqualValues(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
145
-
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
146
-
assert.EqualValues(t, expectedFileResponse.Commit.Author.Email, fileResponse.Commit.Author.Email)
147
-
assert.EqualValues(t, expectedFileResponse.Commit.Author.Name, fileResponse.Commit.Author.Name)
143
+
assert.Equal(t, expectedFileResponse.Content, fileResponse.Content)
144
+
assert.Equal(t, expectedFileResponse.Commit.SHA, fileResponse.Commit.SHA)
145
+
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, fileResponse.Commit.HTMLURL)
146
+
assert.Equal(t, expectedFileResponse.Commit.Author.Email, fileResponse.Commit.Author.Email)
147
+
assert.Equal(t, expectedFileResponse.Commit.Author.Name, fileResponse.Commit.Author.Name)
148
148
gitRepo.Close()
149
149
}
150
150
···
163
163
expectedSHA := "08bd14b2e2852529157324de9c226b3364e76136"
164
164
expectedHTMLURL := fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/new_branch/update/file%d.txt", fileID)
165
165
expectedDownloadURL := fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/new_branch/update/file%d.txt", fileID)
166
-
assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA)
167
-
assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
168
-
assert.EqualValues(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
169
-
assert.EqualValues(t, updateFileOptions.Message+"\n", fileResponse.Commit.Message)
166
+
assert.Equal(t, expectedSHA, fileResponse.Content.SHA)
167
+
assert.Equal(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
168
+
assert.Equal(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
169
+
assert.Equal(t, updateFileOptions.Message+"\n", fileResponse.Commit.Message)
170
170
171
171
// Test updating a file and renaming it
172
172
updateFileOptions = getUpdateFileOptions()
···
183
183
expectedSHA = "08bd14b2e2852529157324de9c226b3364e76136"
184
184
expectedHTMLURL = fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/master/rename/update/file%d.txt", fileID)
185
185
expectedDownloadURL = fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/master/rename/update/file%d.txt", fileID)
186
-
assert.EqualValues(t, expectedSHA, fileResponse.Content.SHA)
187
-
assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
188
-
assert.EqualValues(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
186
+
assert.Equal(t, expectedSHA, fileResponse.Content.SHA)
187
+
assert.Equal(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
188
+
assert.Equal(t, expectedDownloadURL, *fileResponse.Content.DownloadURL)
189
189
190
190
// Test updating a file without a message
191
191
updateFileOptions = getUpdateFileOptions()
···
199
199
resp = MakeRequest(t, req, http.StatusOK)
200
200
DecodeJSON(t, resp, &fileResponse)
201
201
expectedMessage := "Update " + treePath + "\n"
202
-
assert.EqualValues(t, expectedMessage, fileResponse.Commit.Message)
202
+
assert.Equal(t, expectedMessage, fileResponse.Commit.Message)
203
203
204
204
// Test updating a file with the wrong SHA
205
205
fileID++
+19
-19
tests/integration/api_repo_files_change_test.go
+19
-19
tests/integration/api_repo_files_change_test.go
···
105
105
DecodeJSON(t, resp, &filesResponse)
106
106
107
107
// check create file
108
-
assert.EqualValues(t, expectedCreateFileResponse.Content, filesResponse.Files[0])
108
+
assert.Equal(t, expectedCreateFileResponse.Content, filesResponse.Files[0])
109
109
110
110
// check update file
111
-
assert.EqualValues(t, expectedUpdateFileResponse.Content, filesResponse.Files[1])
111
+
assert.Equal(t, expectedUpdateFileResponse.Content, filesResponse.Files[1])
112
112
113
113
// test commit info
114
-
assert.EqualValues(t, expectedCreateFileResponse.Commit.SHA, filesResponse.Commit.SHA)
115
-
assert.EqualValues(t, expectedCreateFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
116
-
assert.EqualValues(t, expectedCreateFileResponse.Commit.Author.Email, filesResponse.Commit.Author.Email)
117
-
assert.EqualValues(t, expectedCreateFileResponse.Commit.Author.Name, filesResponse.Commit.Author.Name)
118
-
assert.EqualValues(t, expectedCreateFileResponse.Commit.Committer.Email, filesResponse.Commit.Committer.Email)
119
-
assert.EqualValues(t, expectedCreateFileResponse.Commit.Committer.Name, filesResponse.Commit.Committer.Name)
114
+
assert.Equal(t, expectedCreateFileResponse.Commit.SHA, filesResponse.Commit.SHA)
115
+
assert.Equal(t, expectedCreateFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
116
+
assert.Equal(t, expectedCreateFileResponse.Commit.Author.Email, filesResponse.Commit.Author.Email)
117
+
assert.Equal(t, expectedCreateFileResponse.Commit.Author.Name, filesResponse.Commit.Author.Name)
118
+
assert.Equal(t, expectedCreateFileResponse.Commit.Committer.Email, filesResponse.Commit.Committer.Email)
119
+
assert.Equal(t, expectedCreateFileResponse.Commit.Committer.Name, filesResponse.Commit.Committer.Name)
120
120
121
121
// test delete file
122
122
assert.Nil(t, filesResponse.Files[2])
···
149
149
expectedUpdateSHA := "08bd14b2e2852529157324de9c226b3364e76136"
150
150
expectedUpdateHTMLURL := fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/new_branch/update/file%d.txt", fileID)
151
151
expectedUpdateDownloadURL := fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/new_branch/update/file%d.txt", fileID)
152
-
assert.EqualValues(t, expectedCreateSHA, filesResponse.Files[0].SHA)
153
-
assert.EqualValues(t, expectedCreateHTMLURL, *filesResponse.Files[0].HTMLURL)
154
-
assert.EqualValues(t, expectedCreateDownloadURL, *filesResponse.Files[0].DownloadURL)
155
-
assert.EqualValues(t, expectedUpdateSHA, filesResponse.Files[1].SHA)
156
-
assert.EqualValues(t, expectedUpdateHTMLURL, *filesResponse.Files[1].HTMLURL)
157
-
assert.EqualValues(t, expectedUpdateDownloadURL, *filesResponse.Files[1].DownloadURL)
152
+
assert.Equal(t, expectedCreateSHA, filesResponse.Files[0].SHA)
153
+
assert.Equal(t, expectedCreateHTMLURL, *filesResponse.Files[0].HTMLURL)
154
+
assert.Equal(t, expectedCreateDownloadURL, *filesResponse.Files[0].DownloadURL)
155
+
assert.Equal(t, expectedUpdateSHA, filesResponse.Files[1].SHA)
156
+
assert.Equal(t, expectedUpdateHTMLURL, *filesResponse.Files[1].HTMLURL)
157
+
assert.Equal(t, expectedUpdateDownloadURL, *filesResponse.Files[1].DownloadURL)
158
158
assert.Nil(t, filesResponse.Files[2])
159
159
160
-
assert.EqualValues(t, changeFilesOptions.Message+"\n", filesResponse.Commit.Message)
160
+
assert.Equal(t, changeFilesOptions.Message+"\n", filesResponse.Commit.Message)
161
161
162
162
// Test updating a file and renaming it
163
163
changeFilesOptions = getChangeFilesOptions()
···
175
175
expectedUpdateSHA = "08bd14b2e2852529157324de9c226b3364e76136"
176
176
expectedUpdateHTMLURL = fmt.Sprintf(setting.AppURL+"user2/repo1/src/branch/master/rename/update/file%d.txt", fileID)
177
177
expectedUpdateDownloadURL = fmt.Sprintf(setting.AppURL+"user2/repo1/raw/branch/master/rename/update/file%d.txt", fileID)
178
-
assert.EqualValues(t, expectedUpdateSHA, filesResponse.Files[0].SHA)
179
-
assert.EqualValues(t, expectedUpdateHTMLURL, *filesResponse.Files[0].HTMLURL)
180
-
assert.EqualValues(t, expectedUpdateDownloadURL, *filesResponse.Files[0].DownloadURL)
178
+
assert.Equal(t, expectedUpdateSHA, filesResponse.Files[0].SHA)
179
+
assert.Equal(t, expectedUpdateHTMLURL, *filesResponse.Files[0].HTMLURL)
180
+
assert.Equal(t, expectedUpdateDownloadURL, *filesResponse.Files[0].DownloadURL)
181
181
182
182
// Test updating a file without a message
183
183
changeFilesOptions = getChangeFilesOptions()
···
197
197
resp = MakeRequest(t, req, http.StatusCreated)
198
198
DecodeJSON(t, resp, &filesResponse)
199
199
expectedMessage := fmt.Sprintf("Add %v\nUpdate %v\nDelete %v\n", createTreePath, updateTreePath, deleteTreePath)
200
-
assert.EqualValues(t, expectedMessage, filesResponse.Commit.Message)
200
+
assert.Equal(t, expectedMessage, filesResponse.Commit.Message)
201
201
202
202
// Test updating a file with the wrong SHA
203
203
fileID++
+5
-5
tests/integration/api_repo_get_contents_list_test.go
+5
-5
tests/integration/api_repo_get_contents_list_test.go
···
100
100
lastCommit, err := gitRepo.GetCommitByPath("README.md")
101
101
require.NoError(t, err)
102
102
expectedContentsListResponse := getExpectedContentsListResponseForContents(ref, refType, lastCommit.ID.String())
103
-
assert.EqualValues(t, expectedContentsListResponse, contentsListResponse)
103
+
assert.Equal(t, expectedContentsListResponse, contentsListResponse)
104
104
105
105
// No ref
106
106
refType = "branch"
···
110
110
assert.NotNil(t, contentsListResponse)
111
111
112
112
expectedContentsListResponse = getExpectedContentsListResponseForContents(repo1.DefaultBranch, refType, lastCommit.ID.String())
113
-
assert.EqualValues(t, expectedContentsListResponse, contentsListResponse)
113
+
assert.Equal(t, expectedContentsListResponse, contentsListResponse)
114
114
115
115
// ref is the branch we created above in setup
116
116
ref = newBranch
···
124
124
lastCommit, err = branchCommit.GetCommitByPath("README.md")
125
125
require.NoError(t, err)
126
126
expectedContentsListResponse = getExpectedContentsListResponseForContents(ref, refType, lastCommit.ID.String())
127
-
assert.EqualValues(t, expectedContentsListResponse, contentsListResponse)
127
+
assert.Equal(t, expectedContentsListResponse, contentsListResponse)
128
128
129
129
// ref is the new tag we created above in setup
130
130
ref = newTag
···
138
138
lastCommit, err = tagCommit.GetCommitByPath("README.md")
139
139
require.NoError(t, err)
140
140
expectedContentsListResponse = getExpectedContentsListResponseForContents(ref, refType, lastCommit.ID.String())
141
-
assert.EqualValues(t, expectedContentsListResponse, contentsListResponse)
141
+
assert.Equal(t, expectedContentsListResponse, contentsListResponse)
142
142
143
143
// ref is a commit
144
144
ref = commitID
···
148
148
DecodeJSON(t, resp, &contentsListResponse)
149
149
assert.NotNil(t, contentsListResponse)
150
150
expectedContentsListResponse = getExpectedContentsListResponseForContents(ref, refType, commitID)
151
-
assert.EqualValues(t, expectedContentsListResponse, contentsListResponse)
151
+
assert.Equal(t, expectedContentsListResponse, contentsListResponse)
152
152
153
153
// Test file contents a file with a bad ref
154
154
ref = "badref"
+8
-8
tests/integration/api_repo_get_contents_test.go
+8
-8
tests/integration/api_repo_get_contents_test.go
···
102
102
assert.NotNil(t, contentsResponse)
103
103
lastCommit, _ := gitRepo.GetCommitByPath("README.md")
104
104
expectedContentsResponse := getExpectedContentsResponseForContents(ref, refType, lastCommit.ID.String())
105
-
assert.EqualValues(t, *expectedContentsResponse, contentsResponse)
105
+
assert.Equal(t, *expectedContentsResponse, contentsResponse)
106
106
107
107
// No ref
108
108
refType = "branch"
···
111
111
DecodeJSON(t, resp, &contentsResponse)
112
112
assert.NotNil(t, contentsResponse)
113
113
expectedContentsResponse = getExpectedContentsResponseForContents(repo1.DefaultBranch, refType, lastCommit.ID.String())
114
-
assert.EqualValues(t, *expectedContentsResponse, contentsResponse)
114
+
assert.Equal(t, *expectedContentsResponse, contentsResponse)
115
115
116
116
// ref is the branch we created above in setup
117
117
ref = newBranch
···
123
123
branchCommit, _ := gitRepo.GetBranchCommit(ref)
124
124
lastCommit, _ = branchCommit.GetCommitByPath("README.md")
125
125
expectedContentsResponse = getExpectedContentsResponseForContents(ref, refType, lastCommit.ID.String())
126
-
assert.EqualValues(t, *expectedContentsResponse, contentsResponse)
126
+
assert.Equal(t, *expectedContentsResponse, contentsResponse)
127
127
128
128
// ref is the new tag we created above in setup
129
129
ref = newTag
···
135
135
tagCommit, _ := gitRepo.GetTagCommit(ref)
136
136
lastCommit, _ = tagCommit.GetCommitByPath("README.md")
137
137
expectedContentsResponse = getExpectedContentsResponseForContents(ref, refType, lastCommit.ID.String())
138
-
assert.EqualValues(t, *expectedContentsResponse, contentsResponse)
138
+
assert.Equal(t, *expectedContentsResponse, contentsResponse)
139
139
140
140
// ref is a commit
141
141
ref = commitID
···
145
145
DecodeJSON(t, resp, &contentsResponse)
146
146
assert.NotNil(t, contentsResponse)
147
147
expectedContentsResponse = getExpectedContentsResponseForContents(ref, refType, commitID)
148
-
assert.EqualValues(t, *expectedContentsResponse, contentsResponse)
148
+
assert.Equal(t, *expectedContentsResponse, contentsResponse)
149
149
150
150
// Test file contents a file with a bad ref
151
151
ref = "badref"
···
181
181
resp := MakeRequest(t, NewRequest(t, http.MethodGet, noRef), http.StatusOK)
182
182
raw, err := io.ReadAll(resp.Body)
183
183
require.NoError(t, err)
184
-
assert.EqualValues(t, content, string(raw))
184
+
assert.Equal(t, content, string(raw))
185
185
186
186
resp = MakeRequest(t, NewRequest(t, http.MethodGet, refInPath), http.StatusOK)
187
187
raw, err = io.ReadAll(resp.Body)
188
188
require.NoError(t, err)
189
-
assert.EqualValues(t, content, string(raw))
189
+
assert.Equal(t, content, string(raw))
190
190
191
191
resp = MakeRequest(t, NewRequest(t, http.MethodGet, refInQuery), http.StatusOK)
192
192
raw, err = io.ReadAll(resp.Body)
193
193
require.NoError(t, err)
194
-
assert.EqualValues(t, content, string(raw))
194
+
assert.Equal(t, content, string(raw))
195
195
})
196
196
}
+11
-11
tests/integration/api_repo_git_commits_test.go
+11
-11
tests/integration/api_repo_git_commits_test.go
···
72
72
DecodeJSON(t, resp, &apiData)
73
73
74
74
assert.Len(t, apiData, 2)
75
-
assert.EqualValues(t, "cfe3b3c1fd36fba04f9183287b106497e1afe986", apiData[0].CommitMeta.SHA)
75
+
assert.Equal(t, "cfe3b3c1fd36fba04f9183287b106497e1afe986", apiData[0].CommitMeta.SHA)
76
76
compareCommitFiles(t, []string{"link_hi", "test.csv"}, apiData[0].Files)
77
-
assert.EqualValues(t, "c8e31bc7688741a5287fcde4fbb8fc129ca07027", apiData[1].CommitMeta.SHA)
77
+
assert.Equal(t, "c8e31bc7688741a5287fcde4fbb8fc129ca07027", apiData[1].CommitMeta.SHA)
78
78
compareCommitFiles(t, []string{"test.csv"}, apiData[1].Files)
79
79
80
-
assert.EqualValues(t, "2", resp.Header().Get("X-Total"))
80
+
assert.Equal(t, "2", resp.Header().Get("X-Total"))
81
81
}
82
82
83
83
func TestAPIReposGitCommitListNotMaster(t *testing.T) {
···
96
96
DecodeJSON(t, resp, &apiData)
97
97
98
98
assert.Len(t, apiData, 3)
99
-
assert.EqualValues(t, "69554a64c1e6030f051e5c3f94bfbd773cd6a324", apiData[0].CommitMeta.SHA)
99
+
assert.Equal(t, "69554a64c1e6030f051e5c3f94bfbd773cd6a324", apiData[0].CommitMeta.SHA)
100
100
compareCommitFiles(t, []string{"readme.md"}, apiData[0].Files)
101
-
assert.EqualValues(t, "27566bd5738fc8b4e3fef3c5e72cce608537bd95", apiData[1].CommitMeta.SHA)
101
+
assert.Equal(t, "27566bd5738fc8b4e3fef3c5e72cce608537bd95", apiData[1].CommitMeta.SHA)
102
102
compareCommitFiles(t, []string{"readme.md"}, apiData[1].Files)
103
-
assert.EqualValues(t, "5099b81332712fe655e34e8dd63574f503f61811", apiData[2].CommitMeta.SHA)
103
+
assert.Equal(t, "5099b81332712fe655e34e8dd63574f503f61811", apiData[2].CommitMeta.SHA)
104
104
compareCommitFiles(t, []string{"readme.md"}, apiData[2].Files)
105
105
106
-
assert.EqualValues(t, "3", resp.Header().Get("X-Total"))
106
+
assert.Equal(t, "3", resp.Header().Get("X-Total"))
107
107
}
108
108
109
109
func TestAPIReposGitCommitListPage2Empty(t *testing.T) {
···
177
177
reqDiff := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.diff", user.Name).
178
178
AddTokenAuth(token)
179
179
resp := MakeRequest(t, reqDiff, http.StatusOK)
180
-
assert.EqualValues(t,
180
+
assert.Equal(t,
181
181
"commit f27c2b2b03dcab38beaf89b0ab4ff61f6de63441\nAuthor: User2 <user2@example.com>\nDate: Sun Aug 6 19:55:01 2017 +0200\n\n good signed commit\n\ndiff --git a/readme.md b/readme.md\nnew file mode 100644\nindex 0000000..458121c\n--- /dev/null\n+++ b/readme.md\n@@ -0,0 +1 @@\n+good sign\n",
182
182
resp.Body.String())
183
183
···
185
185
reqPatch := NewRequestf(t, "GET", "/api/v1/repos/%s/repo16/git/commits/f27c2b2b03dcab38beaf89b0ab4ff61f6de63441.patch", user.Name).
186
186
AddTokenAuth(token)
187
187
resp = MakeRequest(t, reqPatch, http.StatusOK)
188
-
assert.EqualValues(t,
188
+
assert.Equal(t,
189
189
"From f27c2b2b03dcab38beaf89b0ab4ff61f6de63441 Mon Sep 17 00:00:00 2001\nFrom: User2 <user2@example.com>\nDate: Sun, 6 Aug 2017 19:55:01 +0200\nSubject: [PATCH] good signed commit\n\n---\n readme.md | 1 +\n 1 file changed, 1 insertion(+)\n create mode 100644 readme.md\n\ndiff --git a/readme.md b/readme.md\nnew file mode 100644\nindex 0000000..458121c\n--- /dev/null\n+++ b/readme.md\n@@ -0,0 +1 @@\n+good sign\n",
190
190
resp.Body.String())
191
191
}
···
208
208
assert.Equal(t, "f27c2b2b03dcab38beaf89b0ab4ff61f6de63441", apiData[0].CommitMeta.SHA)
209
209
compareCommitFiles(t, []string{"readme.md"}, apiData[0].Files)
210
210
211
-
assert.EqualValues(t, "1", resp.Header().Get("X-Total"))
211
+
assert.Equal(t, "1", resp.Header().Get("X-Total"))
212
212
}
213
213
214
214
func TestGetFileHistoryNotOnMaster(t *testing.T) {
···
229
229
assert.Equal(t, "c8e31bc7688741a5287fcde4fbb8fc129ca07027", apiData[0].CommitMeta.SHA)
230
230
compareCommitFiles(t, []string{"test.csv"}, apiData[0].Files)
231
231
232
-
assert.EqualValues(t, "1", resp.Header().Get("X-Total"))
232
+
assert.Equal(t, "1", resp.Header().Get("X-Total"))
233
233
}
+4
-4
tests/integration/api_repo_lfs_locks_test.go
+4
-4
tests/integration/api_repo_lfs_locks_test.go
···
112
112
var lfsLock api.LFSLockResponse
113
113
DecodeJSON(t, resp, &lfsLock)
114
114
assert.Equal(t, test.user.Name, lfsLock.Lock.Owner.Name)
115
-
assert.EqualValues(t, lfsLock.Lock.LockedAt.Format(time.RFC3339), lfsLock.Lock.LockedAt.Format(time.RFC3339Nano)) // locked at should be rounded to second
115
+
assert.Equal(t, lfsLock.Lock.LockedAt.Format(time.RFC3339), lfsLock.Lock.LockedAt.Format(time.RFC3339Nano)) // locked at should be rounded to second
116
116
for _, id := range test.addTime {
117
117
resultsTests[id].locksTimes = append(resultsTests[id].locksTimes, time.Now())
118
118
}
···
129
129
DecodeJSON(t, resp, &lfsLocks)
130
130
assert.Len(t, lfsLocks.Locks, test.totalCount)
131
131
for i, lock := range lfsLocks.Locks {
132
-
assert.EqualValues(t, test.locksOwners[i].Name, lock.Owner.Name)
132
+
assert.Equal(t, test.locksOwners[i].Name, lock.Owner.Name)
133
133
assert.WithinDuration(t, test.locksTimes[i], lock.LockedAt, 10*time.Second)
134
-
assert.EqualValues(t, lock.LockedAt.Format(time.RFC3339), lock.LockedAt.Format(time.RFC3339Nano)) // locked at should be rounded to second
134
+
assert.Equal(t, lock.LockedAt.Format(time.RFC3339), lock.LockedAt.Format(time.RFC3339Nano)) // locked at should be rounded to second
135
135
}
136
136
137
137
req = NewRequestWithJSON(t, "POST", fmt.Sprintf("/%s.git/info/lfs/locks/verify", test.repo.FullName()), map[string]string{})
···
143
143
assert.Len(t, lfsLocksVerify.Ours, test.oursCount)
144
144
assert.Len(t, lfsLocksVerify.Theirs, test.theirsCount)
145
145
for _, lock := range lfsLocksVerify.Ours {
146
-
assert.EqualValues(t, test.user.Name, lock.Owner.Name)
146
+
assert.Equal(t, test.user.Name, lock.Owner.Name)
147
147
deleteTests = append(deleteTests, struct {
148
148
user *user_model.User
149
149
repo *repo_model.Repository
+1
-1
tests/integration/api_repo_lfs_migrate_test.go
+1
-1
tests/integration/api_repo_lfs_migrate_test.go
···
41
41
LFS: true,
42
42
}).AddTokenAuth(token)
43
43
resp := MakeRequest(t, req, NoExpectedStatus)
44
-
assert.EqualValues(t, http.StatusCreated, resp.Code)
44
+
assert.Equal(t, http.StatusCreated, resp.Code)
45
45
46
46
store := lfs.NewContentStore()
47
47
ok, _ := store.Verify(lfs.Pointer{Oid: "fb8f7d8435968c4f82a726a92395be4d16f2f63116caf36c8ad35c60831ab041", Size: 6})
+2
-2
tests/integration/api_repo_raw_test.go
+2
-2
tests/integration/api_repo_raw_test.go
···
30
30
req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/raw/%s/README.md", user.Name, ref).
31
31
AddTokenAuth(token)
32
32
resp := MakeRequest(t, req, http.StatusOK)
33
-
assert.EqualValues(t, "file", resp.Header().Get("x-gitea-object-type"))
33
+
assert.Equal(t, "file", resp.Header().Get("x-gitea-object-type"))
34
34
}
35
35
// Test default branch
36
36
req := NewRequestf(t, "GET", "/api/v1/repos/%s/repo1/raw/README.md", user.Name).
37
37
AddTokenAuth(token)
38
38
resp := MakeRequest(t, req, http.StatusOK)
39
-
assert.EqualValues(t, "file", resp.Header().Get("x-gitea-object-type"))
39
+
assert.Equal(t, "file", resp.Header().Get("x-gitea-object-type"))
40
40
}
+6
-6
tests/integration/api_repo_teams_test.go
+6
-6
tests/integration/api_repo_teams_test.go
···
37
37
var teams []*api.Team
38
38
DecodeJSON(t, res, &teams)
39
39
if assert.Len(t, teams, 2) {
40
-
assert.EqualValues(t, "Owners", teams[0].Name)
40
+
assert.Equal(t, "Owners", teams[0].Name)
41
41
assert.True(t, teams[0].CanCreateOrgRepo)
42
42
assert.True(t, util.SliceSortedEqual(unit.AllUnitKeyNames(), teams[0].Units))
43
-
assert.EqualValues(t, "owner", teams[0].Permission)
43
+
assert.Equal(t, "owner", teams[0].Permission)
44
44
45
-
assert.EqualValues(t, "test_team", teams[1].Name)
45
+
assert.Equal(t, "test_team", teams[1].Name)
46
46
assert.False(t, teams[1].CanCreateOrgRepo)
47
-
assert.EqualValues(t, []string{"repo.issues"}, teams[1].Units)
48
-
assert.EqualValues(t, "write", teams[1].Permission)
47
+
assert.Equal(t, []string{"repo.issues"}, teams[1].Units)
48
+
assert.Equal(t, "write", teams[1].Permission)
49
49
}
50
50
51
51
// IsTeam
···
54
54
res = MakeRequest(t, req, http.StatusOK)
55
55
var team *api.Team
56
56
DecodeJSON(t, res, &team)
57
-
assert.EqualValues(t, teams[1], team)
57
+
assert.Equal(t, teams[1], team)
58
58
59
59
req = NewRequest(t, "GET", fmt.Sprintf("/api/v1/repos/%s/teams/%s", publicOrgRepo.FullName(), "NonExistingTeam")).
60
60
AddTokenAuth(token)
+20
-22
tests/integration/api_repo_test.go
+20
-22
tests/integration/api_repo_test.go
···
39
39
unittest.Cond("is_private = ?", false))
40
40
assert.Len(t, apiRepos, expectedLen)
41
41
for _, repo := range apiRepos {
42
-
assert.EqualValues(t, user.ID, repo.Owner.ID)
42
+
assert.Equal(t, user.ID, repo.Owner.ID)
43
43
assert.False(t, repo.Private)
44
44
}
45
45
}
···
268
268
resp := MakeRequest(t, req, http.StatusOK)
269
269
DecodeJSON(t, resp, &repo)
270
270
assert.EqualValues(t, 1, repo.ID)
271
-
assert.EqualValues(t, "repo1", repo.Name)
272
-
assert.EqualValues(t, 2, repo.Releases)
273
-
assert.EqualValues(t, 1, repo.OpenIssues)
274
-
assert.EqualValues(t, 3, repo.OpenPulls)
271
+
assert.Equal(t, "repo1", repo.Name)
272
+
assert.Equal(t, 2, repo.Releases)
273
+
assert.Equal(t, 1, repo.OpenIssues)
274
+
assert.Equal(t, 3, repo.OpenPulls)
275
275
276
276
req = NewRequest(t, "GET", "/api/v1/repos/user12/repo10")
277
277
resp = MakeRequest(t, req, http.StatusOK)
278
278
DecodeJSON(t, resp, &repo)
279
279
assert.EqualValues(t, 10, repo.ID)
280
-
assert.EqualValues(t, "repo10", repo.Name)
281
-
assert.EqualValues(t, 1, repo.OpenPulls)
282
-
assert.EqualValues(t, 1, repo.Forks)
280
+
assert.Equal(t, "repo10", repo.Name)
281
+
assert.Equal(t, 1, repo.OpenPulls)
282
+
assert.Equal(t, 1, repo.Forks)
283
283
284
284
req = NewRequest(t, "GET", "/api/v1/repos/user5/repo4")
285
285
resp = MakeRequest(t, req, http.StatusOK)
286
286
DecodeJSON(t, resp, &repo)
287
287
assert.EqualValues(t, 4, repo.ID)
288
-
assert.EqualValues(t, "repo4", repo.Name)
289
-
assert.EqualValues(t, 1, repo.Stars)
288
+
assert.Equal(t, "repo4", repo.Name)
289
+
assert.Equal(t, 1, repo.Stars)
290
290
}
291
291
292
292
func TestAPIOrgRepos(t *testing.T) {
···
339
339
var units []unit_model.Type
340
340
units = append(units, unit_model.TypeCode)
341
341
342
-
if err := repo_service.UpdateRepositoryUnits(db.DefaultContext, repo21, nil, units); err != nil {
343
-
assert.Fail(t, "should have been able to delete code repository unit; failed to %v", err)
344
-
}
342
+
require.NoError(t, repo_service.UpdateRepositoryUnits(db.DefaultContext, repo21, nil, units))
345
343
assert.False(t, repo21.UnitEnabled(db.DefaultContext, unit_model.TypeCode))
346
344
347
345
session := loginUser(t, "user2")
···
405
403
case "Remote visit addressed rate limitation.":
406
404
t.Log("test hit github rate limitation")
407
405
case "You can not import from disallowed hosts.":
408
-
assert.EqualValues(t, "private-ip", testCase.repoName)
406
+
assert.Equal(t, "private-ip", testCase.repoName)
409
407
default:
410
-
assert.FailNow(t, "unexpected error '%v' on url '%s'", respJSON["message"], testCase.cloneURL)
408
+
assert.FailNow(t, "unexpected error", "'%v' on url '%s'", respJSON["message"], testCase.cloneURL)
411
409
}
412
410
} else {
413
-
assert.EqualValues(t, testCase.expectedStatus, resp.Code)
411
+
assert.Equal(t, testCase.expectedStatus, resp.Code)
414
412
}
415
413
}
416
414
}
···
748
746
req := NewRequest(t, "GET", "/api/v1/repos/user2/repo1")
749
747
resp := MakeRequest(t, req, http.StatusOK)
750
748
DecodeJSON(t, resp, &repo)
751
-
assert.EqualValues(t, "sha1", repo.ObjectFormatName)
749
+
assert.Equal(t, "sha1", repo.ObjectFormatName)
752
750
}
753
751
754
752
func TestAPIRepoCommitPull(t *testing.T) {
···
798
796
DecodeJSON(t, resp, &repos)
799
797
800
798
assert.Len(t, repos, 2)
801
-
assert.EqualValues(t, "big_test_private_4", repos[0].Name)
799
+
assert.Equal(t, "big_test_private_4", repos[0].Name)
802
800
// Postgres doesn't do ascii sorting.
803
801
if setting.Database.Type.IsPostgreSQL() {
804
-
assert.EqualValues(t, "commitsonpr", repos[1].Name)
802
+
assert.Equal(t, "commitsonpr", repos[1].Name)
805
803
} else {
806
-
assert.EqualValues(t, "commits_search_test", repos[1].Name)
804
+
assert.Equal(t, "commits_search_test", repos[1].Name)
807
805
}
808
806
})
809
807
···
815
813
DecodeJSON(t, resp, &repos)
816
814
817
815
assert.Len(t, repos, 2)
818
-
assert.EqualValues(t, "utf8", repos[0].Name)
819
-
assert.EqualValues(t, "test_workflows", repos[1].Name)
816
+
assert.Equal(t, "utf8", repos[0].Name)
817
+
assert.Equal(t, "test_workflows", repos[1].Name)
820
818
})
821
819
}
+3
-3
tests/integration/api_repo_topic_test.go
+3
-3
tests/integration/api_repo_topic_test.go
···
62
62
res := MakeRequest(t, NewRequest(t, "GET", searchURL.String()), http.StatusOK)
63
63
DecodeJSON(t, res, &topics)
64
64
assert.Len(t, topics.TopicNames, 4)
65
-
assert.EqualValues(t, "6", res.Header().Get("x-total-count"))
65
+
assert.Equal(t, "6", res.Header().Get("x-total-count"))
66
66
67
67
query.Add("q", "topic")
68
68
searchURL.RawQuery = query.Encode()
···
76
76
DecodeJSON(t, res, &topics)
77
77
if assert.Len(t, topics.TopicNames, 1) {
78
78
assert.EqualValues(t, 2, topics.TopicNames[0].ID)
79
-
assert.EqualValues(t, "database", topics.TopicNames[0].Name)
80
-
assert.EqualValues(t, 1, topics.TopicNames[0].RepoCount)
79
+
assert.Equal(t, "database", topics.TopicNames[0].Name)
80
+
assert.Equal(t, 1, topics.TopicNames[0].RepoCount)
81
81
}
82
82
}
83
83
+3
-3
tests/integration/api_settings_test.go
+3
-3
tests/integration/api_settings_test.go
···
30
30
resp = MakeRequest(t, req, http.StatusOK)
31
31
32
32
DecodeJSON(t, resp, &apiSettings)
33
-
assert.EqualValues(t, &api.GeneralAPISettings{
33
+
assert.Equal(t, &api.GeneralAPISettings{
34
34
MaxResponseItems: setting.API.MaxResponseItems,
35
35
DefaultPagingNum: setting.API.DefaultPagingNum,
36
36
DefaultGitTreesPerPage: setting.API.DefaultGitTreesPerPage,
···
42
42
resp = MakeRequest(t, req, http.StatusOK)
43
43
44
44
DecodeJSON(t, resp, &repo)
45
-
assert.EqualValues(t, &api.GeneralRepoSettings{
45
+
assert.Equal(t, &api.GeneralRepoSettings{
46
46
MirrorsDisabled: !setting.Mirror.Enabled,
47
47
HTTPGitDisabled: setting.Repository.DisableHTTPGit,
48
48
MigrationsDisabled: setting.Repository.DisableMigrations,
···
55
55
resp = MakeRequest(t, req, http.StatusOK)
56
56
57
57
DecodeJSON(t, resp, &attachment)
58
-
assert.EqualValues(t, &api.GeneralAttachmentSettings{
58
+
assert.Equal(t, &api.GeneralAttachmentSettings{
59
59
Enabled: setting.Attachment.Enabled,
60
60
AllowedTypes: setting.Attachment.AllowedTypes,
61
61
MaxFiles: setting.Attachment.MaxFiles,
+4
-4
tests/integration/api_team_test.go
+4
-4
tests/integration/api_team_test.go
···
41
41
42
42
var apiTeam api.Team
43
43
DecodeJSON(t, resp, &apiTeam)
44
-
assert.EqualValues(t, team.ID, apiTeam.ID)
44
+
assert.Equal(t, team.ID, apiTeam.ID)
45
45
assert.Equal(t, team.Name, apiTeam.Name)
46
-
assert.EqualValues(t, convert.ToOrganization(db.DefaultContext, org), apiTeam.Organization)
46
+
assert.Equal(t, convert.ToOrganization(db.DefaultContext, org), apiTeam.Organization)
47
47
48
48
// non team member user will not access the teams details
49
49
teamUser2 := unittest.AssertExistsAndLoadBean(t, &organization.TeamUser{ID: 3})
···
248
248
if units != nil {
249
249
sort.StringSlice(units).Sort()
250
250
sort.StringSlice(apiTeam.Units).Sort()
251
-
assert.EqualValues(t, units, apiTeam.Units, "units")
251
+
assert.Equal(t, units, apiTeam.Units, "units")
252
252
}
253
253
if unitsMap != nil {
254
-
assert.EqualValues(t, unitsMap, apiTeam.UnitsMap, "unitsMap")
254
+
assert.Equal(t, unitsMap, apiTeam.UnitsMap, "unitsMap")
255
255
}
256
256
})
257
257
}
+2
-2
tests/integration/api_team_user_test.go
+2
-2
tests/integration/api_team_user_test.go
···
40
40
expectedUser := convert.ToUser(db.DefaultContext, user, user)
41
41
42
42
// test time via unix timestamp
43
-
assert.EqualValues(t, expectedUser.LastLogin.Unix(), user2.LastLogin.Unix())
44
-
assert.EqualValues(t, expectedUser.Created.Unix(), user2.Created.Unix())
43
+
assert.Equal(t, expectedUser.LastLogin.Unix(), user2.LastLogin.Unix())
44
+
assert.Equal(t, expectedUser.Created.Unix(), user2.Created.Unix())
45
45
expectedUser.LastLogin = user2.LastLogin
46
46
expectedUser.Created = user2.Created
47
47
+1
-1
tests/integration/api_token_test.go
+1
-1
tests/integration/api_token_test.go
···
524
524
} else if minRequiredLevel == auth_model.Write {
525
525
unauthorizedLevel = auth_model.Read
526
526
} else {
527
-
assert.FailNow(t, "Invalid test case: Unknown access token scope level: %v", minRequiredLevel)
527
+
assert.FailNow(t, "Invalid test case", "Unknown access token scope level: %v", minRequiredLevel)
528
528
}
529
529
}
530
530
+1
-1
tests/integration/api_twofa_test.go
+1
-1
tests/integration/api_twofa_test.go
+1
-1
tests/integration/api_user_actions_test.go
+1
-1
tests/integration/api_user_actions_test.go
+3
-3
tests/integration/api_user_email_test.go
+3
-3
tests/integration/api_user_email_test.go
···
28
28
var emails []*api.Email
29
29
DecodeJSON(t, resp, &emails)
30
30
31
-
assert.EqualValues(t, []*api.Email{
31
+
assert.Equal(t, []*api.Email{
32
32
{
33
33
Email: "user2@example.com",
34
34
Verified: true,
···
66
66
67
67
var emails []*api.Email
68
68
DecodeJSON(t, resp, &emails)
69
-
assert.EqualValues(t, []*api.Email{
69
+
assert.Equal(t, []*api.Email{
70
70
{
71
71
Email: "user2@example.com",
72
72
Verified: true,
···
119
119
120
120
var emails []*api.Email
121
121
DecodeJSON(t, resp, &emails)
122
-
assert.EqualValues(t, []*api.Email{
122
+
assert.Equal(t, []*api.Email{
123
123
{
124
124
Email: "user2@example.com",
125
125
Verified: true,
+4
-4
tests/integration/api_user_search_test.go
+4
-4
tests/integration/api_user_search_test.go
···
68
68
for _, user := range results.Data {
69
69
assert.Contains(t, user.UserName, query)
70
70
modelUser = unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: user.ID})
71
-
assert.EqualValues(t, modelUser.GetPlaceholderEmail(), user.Email)
71
+
assert.Equal(t, modelUser.GetPlaceholderEmail(), user.Email)
72
72
}
73
73
}
74
74
···
106
106
assert.NotEmpty(t, results.Data)
107
107
if assert.Len(t, results.Data, 1) {
108
108
user := results.Data[0]
109
-
assert.EqualValues(t, user.UserName, systemUser.Name)
110
-
assert.EqualValues(t, user.ID, systemUser.ID)
109
+
assert.Equal(t, user.UserName, systemUser.Name)
110
+
assert.Equal(t, user.ID, systemUser.ID)
111
111
}
112
112
})
113
113
}
···
129
129
for _, user := range results.Data {
130
130
assert.Contains(t, user.UserName, query)
131
131
assert.NotEmpty(t, user.Email)
132
-
assert.EqualValues(t, "private", user.Visibility)
132
+
assert.Equal(t, "private", user.Visibility)
133
133
}
134
134
}
135
135
+3
-3
tests/integration/appearance_settings_test.go
+3
-3
tests/integration/appearance_settings_test.go
···
38
38
39
39
dataTheme, dataThemeExists := page.Find("html").Attr("data-theme")
40
40
assert.True(t, dataThemeExists)
41
-
assert.EqualValues(t, expectedTheme, dataTheme)
41
+
assert.Equal(t, expectedTheme, dataTheme)
42
42
43
43
selectedTheme := page.Find("form[action='/user/settings/appearance/theme'] .menu .item.selected")
44
44
selectorTheme, selectorThemeExists := selectedTheme.Attr("data-value")
45
45
assert.True(t, selectorThemeExists)
46
-
assert.EqualValues(t, expectedTheme, selectorTheme)
47
-
assert.EqualValues(t, expectedName, strings.TrimSpace(selectedTheme.Text()))
46
+
assert.Equal(t, expectedTheme, selectorTheme)
47
+
assert.Equal(t, expectedName, strings.TrimSpace(selectedTheme.Text()))
48
48
}
49
49
50
50
// testSelectedTheme changes user's theme
+1
-1
tests/integration/auth_ldap_test.go
+1
-1
tests/integration/auth_ldap_test.go
···
220
220
binddn, _ = doc.Find(`input[name="bind_dn"]`).Attr("value")
221
221
assert.Equal(t, "uid=gitea,ou=service,dc=planetexpress,dc=com", binddn)
222
222
domainname, _ := doc.Find(`input[name="default_domain_name"]`).Attr("value")
223
-
assert.Equal(t, "", domainname)
223
+
assert.Empty(t, domainname)
224
224
225
225
req = NewRequestWithValues(t, "POST", href, buildAuthSourceLDAPPayload(csrf, "", "", "test.org", "", "", "off"))
226
226
session.MakeRequest(t, req, http.StatusSeeOther)
+1
-1
tests/integration/auth_token_test.go
+1
-1
tests/integration/auth_token_test.go
···
116
116
assert.NotNil(t, rememberCookie)
117
117
118
118
// Check if the password really changed.
119
-
assert.NotEqualValues(t, unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1}).Passwd, user.Passwd)
119
+
assert.NotEqual(t, unittest.AssertExistsAndLoadBean(t, &user_model.User{ID: 1}).Passwd, user.Passwd)
120
120
121
121
// /user/settings/account should provide with a new LTA cookie, so check for that.
122
122
// If LTA cookie provides authentication /user/login shouldn't return status 200.
+3
-3
tests/integration/block_test.go
+3
-3
tests/integration/block_test.go
···
159
159
assert.False(t, unittest.BeanExists(t, &user_model.BlockedUser{BlockID: doer.ID, UserID: org.ID}))
160
160
flashCookie := session.GetCookie(forgejo_context.CookieNameFlash)
161
161
assert.NotNil(t, flashCookie)
162
-
assert.EqualValues(t, "error%3DYou%2Bcannot%2Bblock%2Byourself.", flashCookie.Value)
162
+
assert.Equal(t, "error%3DYou%2Bcannot%2Bblock%2Byourself.", flashCookie.Value)
163
163
})
164
164
}
165
165
···
393
393
394
394
flashCookie := session.GetCookie(forgejo_context.CookieNameFlash)
395
395
assert.NotNil(t, flashCookie)
396
-
assert.EqualValues(t, "error%3DCannot%2Badd%2Bthe%2Bcollaborator%252C%2Bbecause%2Bthe%2Brepository%2Bowner%2Bhas%2Bblocked%2Bthem.", flashCookie.Value)
396
+
assert.Equal(t, "error%3DCannot%2Badd%2Bthe%2Bcollaborator%252C%2Bbecause%2Bthe%2Brepository%2Bowner%2Bhas%2Bblocked%2Bthem.", flashCookie.Value)
397
397
})
398
398
399
399
t.Run("BlockedUser Add doer", func(t *testing.T) {
···
410
410
411
411
flashCookie := session.GetCookie(forgejo_context.CookieNameFlash)
412
412
assert.NotNil(t, flashCookie)
413
-
assert.EqualValues(t, "error%3DCannot%2Badd%2Bthe%2Bcollaborator%252C%2Bbecause%2Bthey%2Bhave%2Bblocked%2Bthe%2Brepository%2Bowner.", flashCookie.Value)
413
+
assert.Equal(t, "error%3DCannot%2Badd%2Bthe%2Bcollaborator%252C%2Bbecause%2Bthey%2Bhave%2Bblocked%2Bthe%2Brepository%2Bowner.", flashCookie.Value)
414
414
})
415
415
})
416
416
+6
-6
tests/integration/cmd_forgejo_actions_test.go
+6
-6
tests/integration/cmd_forgejo_actions_test.go
···
69
69
t.Run(testCase.testName, func(t *testing.T) {
70
70
defer tests.PrintCurrentTest(t)()
71
71
output, err := runMainApp("forgejo-cli", "actions", "register", "--secret", testCase.secret, "--scope", testCase.scope)
72
-
assert.EqualValues(t, "", output)
72
+
assert.Empty(t, output)
73
73
74
74
var exitErr *exec.ExitError
75
75
require.ErrorAs(t, err, &exitErr)
···
110
110
t.Run(testCase.testName, func(t *testing.T) {
111
111
uuid, err := runMainAppWithStdin(testCase.stdin, "forgejo-cli", "actions", "register", testCase.secretOption(), "--scope=org26")
112
112
require.NoError(t, err)
113
-
assert.EqualValues(t, expecteduuid, uuid)
113
+
assert.Equal(t, expecteduuid, uuid)
114
114
})
115
115
}
116
116
···
186
186
for i := 0; i < 2; i++ {
187
187
uuid, err := runMainApp("forgejo-cli", cmd...)
188
188
require.NoError(t, err)
189
-
if assert.EqualValues(t, testCase.uuid, uuid) {
189
+
if assert.Equal(t, testCase.uuid, uuid) {
190
190
ownerName, repoName, found := strings.Cut(testCase.scope, "/")
191
191
action, err := actions_model.GetRunnerByUUID(t.Context(), uuid)
192
192
require.NoError(t, err)
···
199
199
assert.Equal(t, repoName, repo.Name, action.RepoID)
200
200
}
201
201
if testCase.name != "" {
202
-
assert.EqualValues(t, testCase.name, action.Name)
202
+
assert.Equal(t, testCase.name, action.Name)
203
203
}
204
204
if testCase.labels != "" {
205
205
labels := strings.Split(testCase.labels, ",")
206
-
assert.EqualValues(t, labels, action.AgentLabels)
206
+
assert.Equal(t, labels, action.AgentLabels)
207
207
}
208
208
if testCase.version != "" {
209
-
assert.EqualValues(t, testCase.version, action.Version)
209
+
assert.Equal(t, testCase.version, action.Version)
210
210
}
211
211
}
212
212
}
+4
-4
tests/integration/cmd_forgejo_f3_test.go
+4
-4
tests/integration/cmd_forgejo_f3_test.go
···
83
83
user := users.CreateChild(ctx)
84
84
user.FromFormat(userFormat)
85
85
user.Upsert(ctx)
86
-
require.EqualValues(t, user.GetID(), users.GetIDFromName(ctx, userFormat.UserName))
86
+
require.Equal(t, user.GetID(), users.GetIDFromName(ctx, userFormat.UserName))
87
87
88
88
projectFormat := creator.GenerateProject()
89
89
projectFormat.SetID(fixtureProjectID)
···
91
91
project := projects.CreateChild(ctx)
92
92
project.FromFormat(projectFormat)
93
93
project.Upsert(ctx)
94
-
require.EqualValues(t, project.GetID(), projects.GetIDFromName(ctx, projectFormat.Name))
94
+
require.Equal(t, project.GetID(), projects.GetIDFromName(ctx, projectFormat.Name))
95
95
96
96
fromPath = fmt.Sprintf("/forge/users/%s/projects/%s", userFormat.UserName, projectFormat.Name)
97
97
}
···
106
106
user := users.CreateChild(ctx)
107
107
user.FromFormat(userFormat)
108
108
user.Upsert(ctx)
109
-
require.EqualValues(t, user.GetID(), users.GetIDFromName(ctx, userFormat.UserName))
109
+
require.Equal(t, user.GetID(), users.GetIDFromName(ctx, userFormat.UserName))
110
110
111
111
projectFormat := creator.GenerateProject()
112
112
projects = user.MustFind(f3_generic.NewPathFromString("projects"))
113
113
project := projects.CreateChild(ctx)
114
114
project.FromFormat(projectFormat)
115
115
project.Upsert(ctx)
116
-
require.EqualValues(t, project.GetID(), projects.GetIDFromName(ctx, projectFormat.Name))
116
+
require.Equal(t, project.GetID(), projects.GetIDFromName(ctx, projectFormat.Name))
117
117
118
118
toPath = fmt.Sprintf("/forge/users/%s/projects/%s", userFormat.UserName, projectFormat.Name)
119
119
}
+1
-1
tests/integration/comment_roles_system_test.go
+1
-1
tests/integration/comment_roles_system_test.go
···
49
49
resp := MakeRequest(t, req, http.StatusOK)
50
50
htmlDoc := NewHTMLParser(t, resp.Body)
51
51
52
-
assert.EqualValues(t, tc.username, htmlDoc.Find("a.author").Text())
52
+
assert.Equal(t, tc.username, htmlDoc.Find("a.author").Text())
53
53
assert.EqualValues(t, tc.roleCount, htmlDoc.Find(".role-label").Length())
54
54
})
55
55
}
+14
-14
tests/integration/comment_roles_test.go
+14
-14
tests/integration/comment_roles_test.go
···
61
61
response = sessionUser2.MakeRequest(t, NewRequest(t, "GET", path.Join(user, repo, "pulls", testID)), http.StatusOK)
62
62
page = NewHTMLParser(t, response.Body)
63
63
commentHeads := page.Find(".timeline .comment .comment-header .comment-header-right")
64
-
assert.EqualValues(t, 6, commentHeads.Length())
64
+
assert.Equal(t, 6, commentHeads.Length())
65
65
66
66
// Test the first comment and it's label "Owner"
67
67
labels := commentHeads.Eq(0).Find(".role-label")
68
-
assert.EqualValues(t, 1, labels.Length())
68
+
assert.Equal(t, 1, labels.Length())
69
69
testIssueCommentUserLabel(t, labels.Eq(0), "Owner", ownerTooltip)
70
70
71
71
// Test the second (review) comment and it's labels "Author" and "Owner"
72
72
labels = commentHeads.Eq(1).Find(".role-label")
73
-
assert.EqualValues(t, 2, labels.Length())
73
+
assert.Equal(t, 2, labels.Length())
74
74
testIssueCommentUserLabel(t, labels.Eq(0), "Author", authorTooltipPR)
75
75
testIssueCommentUserLabel(t, labels.Eq(1), "Owner", ownerTooltip)
76
76
77
77
// Test the third (review) comment and it's labels "Author" and "Owner"
78
78
labels = commentHeads.Eq(2).Find(".role-label")
79
-
assert.EqualValues(t, 2, labels.Length())
79
+
assert.Equal(t, 2, labels.Length())
80
80
testIssueCommentUserLabel(t, labels.Eq(0), "Author", authorTooltipPR)
81
81
testIssueCommentUserLabel(t, labels.Eq(1), "Owner", ownerTooltip)
82
82
83
83
// Test the fourth comment and it's labels "Author" and "Owner"
84
84
labels = commentHeads.Eq(3).Find(".role-label")
85
-
assert.EqualValues(t, 2, labels.Length())
85
+
assert.Equal(t, 2, labels.Length())
86
86
testIssueCommentUserLabel(t, labels.Eq(0), "Author", authorTooltipPR)
87
87
testIssueCommentUserLabel(t, labels.Eq(1), "Owner", ownerTooltip)
88
88
89
89
// Test the fivth comment and it's label "Contributor"
90
90
labels = commentHeads.Eq(4).Find(".role-label")
91
-
assert.EqualValues(t, 1, labels.Length())
91
+
assert.Equal(t, 1, labels.Length())
92
92
testIssueCommentUserLabel(t, labels.Eq(0), "Contributor", contributorTooltip)
93
93
94
94
// Test the sixth comment and it's label "First-time contributor"
95
95
labels = commentHeads.Eq(5).Find(".role-label")
96
-
assert.EqualValues(t, 1, labels.Length())
96
+
assert.Equal(t, 1, labels.Length())
97
97
testIssueCommentUserLabel(t, labels.Eq(0), "First-time contributor", newContributorTooltip)
98
98
})
99
99
···
123
123
response := sessionUser2.MakeRequest(t, NewRequest(t, "GET", path.Join(user, repo, "issues", testID)), http.StatusOK)
124
124
page := NewHTMLParser(t, response.Body)
125
125
commentHeads := page.Find(".timeline .comment .comment-header .comment-header-right")
126
-
assert.EqualValues(t, 4, commentHeads.Length())
126
+
assert.Equal(t, 4, commentHeads.Length())
127
127
128
128
// Test the first comment and it's label "Owner"
129
129
labels := commentHeads.Eq(0).Find(".role-label")
130
-
assert.EqualValues(t, 1, labels.Length())
130
+
assert.Equal(t, 1, labels.Length())
131
131
testIssueCommentUserLabel(t, labels.Eq(0), "Owner", ownerTooltip)
132
132
133
133
// Test the second comment and it's labels "Author" and "Owner"
134
134
labels = commentHeads.Eq(1).Find(".role-label")
135
-
assert.EqualValues(t, 2, labels.Length())
135
+
assert.Equal(t, 2, labels.Length())
136
136
testIssueCommentUserLabel(t, labels.Eq(0), "Author", authorTooltipIssue)
137
137
testIssueCommentUserLabel(t, labels.Eq(1), "Owner", ownerTooltip)
138
138
139
139
// Test the third comment and it's label "Contributor"
140
140
labels = commentHeads.Eq(2).Find(".role-label")
141
-
assert.EqualValues(t, 1, labels.Length())
141
+
assert.Equal(t, 1, labels.Length())
142
142
testIssueCommentUserLabel(t, labels.Eq(0), "Contributor", contributorTooltip)
143
143
144
144
// Test the fifth comment and it's lack of labels
145
145
labels = commentHeads.Eq(3).Find(".role-label")
146
-
assert.EqualValues(t, 0, labels.Length())
146
+
assert.Equal(t, 0, labels.Length())
147
147
})
148
148
}
149
149
···
153
153
title := label.Text()
154
154
tooltip, exists := label.Attr("data-tooltip-content")
155
155
assert.True(t, exists)
156
-
assert.EqualValues(t, expectedTitle, strings.TrimSpace(title))
157
-
assert.EqualValues(t, expectedTooltip, strings.TrimSpace(tooltip))
156
+
assert.Equal(t, expectedTitle, strings.TrimSpace(title))
157
+
assert.Equal(t, expectedTooltip, strings.TrimSpace(tooltip))
158
158
}
159
159
160
160
// testEasyLeaveIssueComment is used to create a comment on an issue with minimum code and parameters
+10
-10
tests/integration/commit_status_test.go
+10
-10
tests/integration/commit_status_test.go
···
23
23
defer tests.PrintCurrentTest(t)()
24
24
pairs, err := git_model.GetLatestCommitStatusForPairs(db.DefaultContext, nil)
25
25
require.NoError(t, err)
26
-
assert.EqualValues(t, map[int64][]*git_model.CommitStatus{}, pairs)
26
+
assert.Equal(t, map[int64][]*git_model.CommitStatus{}, pairs)
27
27
})
28
28
29
29
t.Run("Repo 1", func(t *testing.T) {
···
31
31
pairs, err := git_model.GetLatestCommitStatusForPairs(db.DefaultContext, []git_model.RepoSHA{{RepoID: 1, SHA: "1234123412341234123412341234123412341234"}})
32
32
require.NoError(t, err)
33
33
34
-
assert.EqualValues(t, map[int64][]*git_model.CommitStatus{
34
+
assert.Equal(t, map[int64][]*git_model.CommitStatus{
35
35
1: {
36
36
{
37
37
ID: 7,
···
77
77
pairs, err := git_model.GetLatestCommitStatusForPairs(db.DefaultContext, []git_model.RepoSHA{{RepoID: 62, SHA: "774f93df12d14931ea93259ae93418da4482fcc1"}})
78
78
require.NoError(t, err)
79
79
80
-
assert.EqualValues(t, map[int64][]*git_model.CommitStatus{
80
+
assert.Equal(t, map[int64][]*git_model.CommitStatus{
81
81
62: {
82
82
{
83
83
ID: 8,
···
100
100
pairs, err := git_model.GetLatestCommitStatusForPairs(db.DefaultContext, []git_model.RepoSHA{{RepoID: 62, SHA: "774f93df12d14931ea93259ae93418da4482fcc"}})
101
101
require.NoError(t, err)
102
102
103
-
assert.EqualValues(t, map[int64][]*git_model.CommitStatus{}, pairs)
103
+
assert.Equal(t, map[int64][]*git_model.CommitStatus{}, pairs)
104
104
})
105
105
106
106
t.Run("SHA with non-existent repo id", func(t *testing.T) {
···
108
108
pairs, err := git_model.GetLatestCommitStatusForPairs(db.DefaultContext, []git_model.RepoSHA{{RepoID: 1, SHA: "774f93df12d14931ea93259ae93418da4482fcc1"}})
109
109
require.NoError(t, err)
110
110
111
-
assert.EqualValues(t, map[int64][]*git_model.CommitStatus{}, pairs)
111
+
assert.Equal(t, map[int64][]*git_model.CommitStatus{}, pairs)
112
112
})
113
113
}
114
114
···
119
119
defer tests.PrintCurrentTest(t)()
120
120
repoStatuses, err := git_model.GetLatestCommitStatusForRepoCommitIDs(db.DefaultContext, 62, nil)
121
121
require.NoError(t, err)
122
-
assert.EqualValues(t, map[string][]*git_model.CommitStatus{}, repoStatuses)
122
+
assert.Equal(t, map[string][]*git_model.CommitStatus{}, repoStatuses)
123
123
})
124
124
125
125
t.Run("Repo 1", func(t *testing.T) {
126
126
defer tests.PrintCurrentTest(t)()
127
127
repoStatuses, err := git_model.GetLatestCommitStatusForRepoCommitIDs(db.DefaultContext, 1, []string{"1234123412341234123412341234123412341234"})
128
128
require.NoError(t, err)
129
-
assert.EqualValues(t, map[string][]*git_model.CommitStatus{
129
+
assert.Equal(t, map[string][]*git_model.CommitStatus{
130
130
"1234123412341234123412341234123412341234": {
131
131
{
132
132
ID: 3,
···
172
172
defer tests.PrintCurrentTest(t)()
173
173
repoStatuses, err := git_model.GetLatestCommitStatusForRepoCommitIDs(db.DefaultContext, 62, []string{"774f93df12d14931ea93259ae93418da4482fcc1"})
174
174
require.NoError(t, err)
175
-
assert.EqualValues(t, map[string][]*git_model.CommitStatus{
175
+
assert.Equal(t, map[string][]*git_model.CommitStatus{
176
176
"774f93df12d14931ea93259ae93418da4482fcc1": {
177
177
{
178
178
ID: 8,
···
194
194
defer tests.PrintCurrentTest(t)()
195
195
repoStatuses, err := git_model.GetLatestCommitStatusForRepoCommitIDs(db.DefaultContext, 62, []string{"774f93df12d14931ea93259ae93418da4482fcc"})
196
196
require.NoError(t, err)
197
-
assert.EqualValues(t, map[string][]*git_model.CommitStatus{}, repoStatuses)
197
+
assert.Equal(t, map[string][]*git_model.CommitStatus{}, repoStatuses)
198
198
})
199
199
200
200
t.Run("non-existent repo ID", func(t *testing.T) {
201
201
defer tests.PrintCurrentTest(t)()
202
202
repoStatuses, err := git_model.GetLatestCommitStatusForRepoCommitIDs(db.DefaultContext, 1, []string{"774f93df12d14931ea93259ae93418da4482fcc"})
203
203
require.NoError(t, err)
204
-
assert.EqualValues(t, map[string][]*git_model.CommitStatus{}, repoStatuses)
204
+
assert.Equal(t, map[string][]*git_model.CommitStatus{}, repoStatuses)
205
205
})
206
206
}
+8
-8
tests/integration/dump_restore_test.go
+8
-8
tests/integration/dump_restore_test.go
···
180
180
}).([]*base.Comment)
181
181
assert.True(c.t, ok)
182
182
for _, comment := range comments {
183
-
assert.EqualValues(c.t, issue.Number, comment.IssueIndex)
183
+
assert.Equal(c.t, issue.Number, comment.IssueIndex)
184
184
}
185
185
}
186
186
···
207
207
comments, ok := c.assertEqual(filename, []base.Comment{}, compareFields{}).([]*base.Comment)
208
208
assert.True(c.t, ok)
209
209
for _, comment := range comments {
210
-
assert.EqualValues(c.t, pr.Number, comment.IssueIndex)
210
+
assert.Equal(c.t, pr.Number, comment.IssueIndex)
211
211
}
212
212
}
213
213
}
···
215
215
func (c *compareDump) assertLoadYAMLFiles(beforeFilename, afterFilename string, before, after any) {
216
216
_, beforeErr := os.Stat(beforeFilename)
217
217
_, afterErr := os.Stat(afterFilename)
218
-
assert.EqualValues(c.t, errors.Is(beforeErr, os.ErrNotExist), errors.Is(afterErr, os.ErrNotExist))
218
+
assert.Equal(c.t, errors.Is(beforeErr, os.ErrNotExist), errors.Is(afterErr, os.ErrNotExist))
219
219
if errors.Is(beforeErr, os.ErrNotExist) {
220
220
return
221
221
}
···
267
267
}
268
268
269
269
func (c *compareDump) assertEqualSlices(before, after reflect.Value, fields compareFields) any {
270
-
assert.EqualValues(c.t, before.Len(), after.Len())
270
+
assert.Equal(c.t, before.Len(), after.Len())
271
271
if before.Len() == after.Len() {
272
272
for i := 0; i < before.Len(); i++ {
273
273
_ = c.assertEqualValues(
···
300
300
assert.True(c.t, ok)
301
301
as, ok := ai.(string)
302
302
assert.True(c.t, ok)
303
-
assert.EqualValues(c.t, compare.transform(bs), compare.transform(as))
303
+
assert.Equal(c.t, compare.transform(bs), compare.transform(as))
304
304
continue
305
305
}
306
306
if compare.before != nil && compare.after != nil {
307
307
//
308
308
// The fields are expected to have different values
309
309
//
310
-
assert.EqualValues(c.t, compare.before, bi)
311
-
assert.EqualValues(c.t, compare.after, ai)
310
+
assert.Equal(c.t, compare.before, bi)
311
+
assert.Equal(c.t, compare.after, ai)
312
312
continue
313
313
}
314
314
if compare.nested != nil {
···
319
319
continue
320
320
}
321
321
}
322
-
assert.EqualValues(c.t, bi, ai)
322
+
assert.Equal(c.t, bi, ai)
323
323
}
324
324
return after.Interface()
325
325
}
+17
-17
tests/integration/editor_test.go
+17
-17
tests/integration/editor_test.go
···
43
43
// Check if master branch has been locked successfully
44
44
flashCookie := session.GetCookie(gitea_context.CookieNameFlash)
45
45
assert.NotNil(t, flashCookie)
46
-
assert.EqualValues(t, "success%3DBranch%2Bprotection%2Bfor%2Brule%2B%2522master%2522%2Bhas%2Bbeen%2Bupdated.", flashCookie.Value)
46
+
assert.Equal(t, "success%3DBranch%2Bprotection%2Bfor%2Brule%2B%2522master%2522%2Bhas%2Bbeen%2Bupdated.", flashCookie.Value)
47
47
48
48
// Request editor page
49
49
req = NewRequest(t, "GET", "/user2/repo1/_new/master/")
···
79
79
80
80
res := make(map[string]string)
81
81
require.NoError(t, json.NewDecoder(resp.Body).Decode(&res))
82
-
assert.EqualValues(t, "/user2/repo1/settings/branches", res["redirect"])
82
+
assert.Equal(t, "/user2/repo1/settings/branches", res["redirect"])
83
83
84
84
// Check if master branch has been locked successfully
85
85
flashCookie = session.GetCookie(gitea_context.CookieNameFlash)
86
86
assert.NotNil(t, flashCookie)
87
-
assert.EqualValues(t, "error%3DRemoving%2Bbranch%2Bprotection%2Brule%2B%25221%2522%2Bfailed.", flashCookie.Value)
87
+
assert.Equal(t, "error%3DRemoving%2Bbranch%2Bprotection%2Brule%2B%25221%2522%2Bfailed.", flashCookie.Value)
88
88
})
89
89
}
90
90
···
113
113
// Verify the change
114
114
req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", branch, filePath))
115
115
resp = session.MakeRequest(t, req, http.StatusOK)
116
-
assert.EqualValues(t, newContent, resp.Body.String())
116
+
assert.Equal(t, newContent, resp.Body.String())
117
117
118
118
return resp
119
119
}
···
144
144
// Verify the change
145
145
req = NewRequest(t, "GET", path.Join(user, repo, "raw/branch", targetBranch, filePath))
146
146
resp = session.MakeRequest(t, req, http.StatusOK)
147
-
assert.EqualValues(t, newContent, resp.Body.String())
147
+
assert.Equal(t, newContent, resp.Body.String())
148
148
149
149
return resp
150
150
}
···
173
173
174
174
placeholder, ok := htmlDoc.Find("input[name='commit_summary']").Attr("placeholder")
175
175
assert.True(t, ok)
176
-
assert.EqualValues(t, `Add "<filename>"`, placeholder)
176
+
assert.Equal(t, `Add "<filename>"`, placeholder)
177
177
}
178
178
179
179
func TestCommitMail(t *testing.T) {
···
188
188
assert.False(t, inactivatedMail.IsActivated)
189
189
190
190
otherEmail := unittest.AssertExistsAndLoadBean(t, &user_model.EmailAddress{ID: 1, IsActivated: true})
191
-
assert.NotEqualValues(t, otherEmail.UID, user.ID)
191
+
assert.NotEqual(t, otherEmail.UID, user.ID)
192
192
193
193
primaryEmail := unittest.AssertExistsAndLoadBean(t, &user_model.EmailAddress{ID: 3, UID: user.ID, IsActivated: true})
194
194
···
277
277
session.MakeRequest(t, req, http.StatusSeeOther)
278
278
if !case2.skipLastCommit {
279
279
newlastCommit, _ := lastCommitAndCSRF(t, case1.link, false)
280
-
assert.NotEqualValues(t, newlastCommit, lastCommit)
280
+
assert.NotEqual(t, newlastCommit, lastCommit)
281
281
}
282
282
283
283
commit, err := gitRepo.GetCommitByPath(case1.fileName)
284
284
require.NoError(t, err)
285
285
286
-
assert.EqualValues(t, "user2", commit.Author.Name)
287
-
assert.EqualValues(t, "user2@noreply.example.org", commit.Author.Email)
288
-
assert.EqualValues(t, "user2", commit.Committer.Name)
289
-
assert.EqualValues(t, "user2@noreply.example.org", commit.Committer.Email)
286
+
assert.Equal(t, "user2", commit.Author.Name)
287
+
assert.Equal(t, "user2@noreply.example.org", commit.Author.Email)
288
+
assert.Equal(t, "user2", commit.Committer.Name)
289
+
assert.Equal(t, "user2@noreply.example.org", commit.Committer.Email)
290
290
})
291
291
292
292
t.Run("Normal", func(t *testing.T) {
···
302
302
session.MakeRequest(t, req, http.StatusSeeOther)
303
303
if !case2.skipLastCommit {
304
304
newlastCommit, _ := lastCommitAndCSRF(t, case2.link, false)
305
-
assert.NotEqualValues(t, newlastCommit, lastCommit)
305
+
assert.NotEqual(t, newlastCommit, lastCommit)
306
306
}
307
307
308
308
commit, err := gitRepo.GetCommitByPath(case2.fileName)
309
309
require.NoError(t, err)
310
310
311
-
assert.EqualValues(t, "user2", commit.Author.Name)
312
-
assert.EqualValues(t, primaryEmail.Email, commit.Author.Email)
313
-
assert.EqualValues(t, "user2", commit.Committer.Name)
314
-
assert.EqualValues(t, primaryEmail.Email, commit.Committer.Email)
311
+
assert.Equal(t, "user2", commit.Author.Name)
312
+
assert.Equal(t, primaryEmail.Email, commit.Author.Email)
313
+
assert.Equal(t, "user2", commit.Committer.Name)
314
+
assert.Equal(t, primaryEmail.Email, commit.Committer.Email)
315
315
})
316
316
}
317
317
+1
-1
tests/integration/empty_repo_test.go
+1
-1
tests/integration/empty_repo_test.go
···
123
123
var fileResponse api.FileResponse
124
124
DecodeJSON(t, resp, &fileResponse)
125
125
expectedHTMLURL := setting.AppURL + "user30/empty/src/branch/new_branch/new-file.txt"
126
-
assert.EqualValues(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
126
+
assert.Equal(t, expectedHTMLURL, *fileResponse.Content.HTMLURL)
127
127
128
128
req = NewRequest(t, "GET", "/user30/empty/src/branch/new_branch/new-file.txt")
129
129
resp = session.MakeRequest(t, req, http.StatusOK)
+2
-2
tests/integration/explore_repos_test.go
+2
-2
tests/integration/explore_repos_test.go
···
25
25
resp := MakeRequest(t, req, http.StatusOK)
26
26
htmlDoc := NewHTMLParser(t, resp.Body).Find("#repo-search-form")
27
27
28
-
assert.EqualValues(t, "Go", htmlDoc.Find("input[name='language']").AttrOr("value", "not found"))
29
-
assert.EqualValues(t, "true", htmlDoc.Find("input[name='topic']").AttrOr("value", "not found"))
28
+
assert.Equal(t, "Go", htmlDoc.Find("input[name='language']").AttrOr("value", "not found"))
29
+
assert.Equal(t, "true", htmlDoc.Find("input[name='topic']").AttrOr("value", "not found"))
30
30
})
31
31
}
+1
-1
tests/integration/feed_repo_test.go
+1
-1
tests/integration/feed_repo_test.go
···
30
30
assert.Contains(t, rss.Channel.Link, "/user2/repo1")
31
31
assert.NotEmpty(t, rss.Channel.PubDate)
32
32
assert.Len(t, rss.Channel.Items, 1)
33
-
assert.EqualValues(t, "issue5", rss.Channel.Items[0].Description)
33
+
assert.Equal(t, "issue5", rss.Channel.Items[0].Description)
34
34
assert.NotEmpty(t, rss.Channel.Items[0].PubDate)
35
35
})
36
36
}
+5
-5
tests/integration/forgejo_confirmation_repo_test.go
+5
-5
tests/integration/forgejo_confirmation_repo_test.go
···
55
55
56
56
flashCookie := session.GetCookie(gitea_context.CookieNameFlash)
57
57
assert.NotNil(t, flashCookie)
58
-
assert.EqualValues(t, "success%3DThis%2Brepository%2Bhas%2Bbeen%2Bmarked%2Bfor%2Btransfer%2Band%2Bawaits%2Bconfirmation%2Bfrom%2B%2522User%2BOne%2522", flashCookie.Value)
58
+
assert.Equal(t, "success%3DThis%2Brepository%2Bhas%2Bbeen%2Bmarked%2Bfor%2Btransfer%2Band%2Bawaits%2Bconfirmation%2Bfrom%2B%2522User%2BOne%2522", flashCookie.Value)
59
59
})
60
60
})
61
61
···
85
85
86
86
flashCookie := session.GetCookie(gitea_context.CookieNameFlash)
87
87
assert.NotNil(t, flashCookie)
88
-
assert.EqualValues(t, "success%3DThe%2Bfork%2Bhas%2Bbeen%2Bconverted%2Binto%2Ba%2Bregular%2Brepository.", flashCookie.Value)
88
+
assert.Equal(t, "success%3DThe%2Bfork%2Bhas%2Bbeen%2Bconverted%2Binto%2Ba%2Bregular%2Brepository.", flashCookie.Value)
89
89
})
90
90
})
91
91
···
118
118
119
119
flashCookie := session.GetCookie(gitea_context.CookieNameFlash)
120
120
assert.NotNil(t, flashCookie)
121
-
assert.EqualValues(t, "success%3DThe%2Brepository%2Bwiki%2527s%2Bbranch%2Bname%2Bhas%2Bbeen%2Bsuccessfully%2Bnormalized.", flashCookie.Value)
121
+
assert.Equal(t, "success%3DThe%2Brepository%2Bwiki%2527s%2Bbranch%2Bname%2Bhas%2Bbeen%2Bsuccessfully%2Bnormalized.", flashCookie.Value)
122
122
})
123
123
})
124
124
···
148
148
149
149
flashCookie := session.GetCookie(gitea_context.CookieNameFlash)
150
150
assert.NotNil(t, flashCookie)
151
-
assert.EqualValues(t, "success%3DThe%2Brepository%2Bwiki%2Bdata%2Bhas%2Bbeen%2Bdeleted.", flashCookie.Value)
151
+
assert.Equal(t, "success%3DThe%2Brepository%2Bwiki%2Bdata%2Bhas%2Bbeen%2Bdeleted.", flashCookie.Value)
152
152
})
153
153
})
154
154
···
178
178
179
179
flashCookie := session.GetCookie(gitea_context.CookieNameFlash)
180
180
assert.NotNil(t, flashCookie)
181
-
assert.EqualValues(t, "success%3DThe%2Brepository%2Bhas%2Bbeen%2Bdeleted.", flashCookie.Value)
181
+
assert.Equal(t, "success%3DThe%2Brepository%2Bhas%2Bbeen%2Bdeleted.", flashCookie.Value)
182
182
})
183
183
})
184
184
}
+1
-1
tests/integration/git_push_test.go
+1
-1
tests/integration/git_push_test.go
···
176
176
177
177
dbBranches := make([]*git_model.Branch, 0)
178
178
require.NoError(t, db.GetEngine(db.DefaultContext).Where("repo_id=?", repo.ID).Find(&dbBranches))
179
-
assert.Equalf(t, len(pushedBranches), len(dbBranches), "mismatched number of branches in db")
179
+
assert.Lenf(t, dbBranches, len(pushedBranches), "mismatched number of branches in db")
180
180
dbBranchesMap := make(map[string]*git_model.Branch, len(dbBranches))
181
181
for _, branch := range dbBranches {
182
182
dbBranchesMap[branch.Name] = branch
+1
-1
tests/integration/git_smart_http_test.go
+1
-1
tests/integration/git_smart_http_test.go
+4
-4
tests/integration/git_test.go
+4
-4
tests/integration/git_test.go
···
462
462
// Check if master branch has been locked successfully
463
463
flashCookie := ctx.Session.GetCookie(gitea_context.CookieNameFlash)
464
464
assert.NotNil(t, flashCookie)
465
-
assert.EqualValues(t, "success%3DBranch%2Bprotection%2Bfor%2Brule%2B%2522"+url.QueryEscape(branch)+"%2522%2Bhas%2Bbeen%2Bupdated.", flashCookie.Value)
465
+
assert.Equal(t, "success%3DBranch%2Bprotection%2Bfor%2Brule%2B%2522"+url.QueryEscape(branch)+"%2522%2Bhas%2Bbeen%2Bupdated.", flashCookie.Value)
466
466
}
467
467
}
468
468
···
578
578
doc := NewHTMLParser(t, resp.Body)
579
579
editButtonCount := doc.doc.Find("div.diff-file-header-actions a[href*='/_edit/']").Length()
580
580
if editable {
581
-
assert.Positive(t, editButtonCount, 0, "Expected to find a button to edit a file in the PR diff view but there were none")
581
+
assert.Positive(t, editButtonCount, "Expected to find a button to edit a file in the PR diff view but there were none")
582
582
} else {
583
583
assert.Equal(t, 0, editButtonCount, "Expected not to find any buttons to edit files in PR diff view but there were some")
584
584
}
···
1035
1035
1036
1036
currentHeadCommitID, err := upstreamGitRepo.GetRefCommitID(pr.GetGitRefName())
1037
1037
require.NoError(t, err)
1038
-
assert.EqualValues(t, headCommitID, currentHeadCommitID)
1038
+
assert.Equal(t, headCommitID, currentHeadCommitID)
1039
1039
})
1040
1040
t.Run("Succeeds", func(t *testing.T) {
1041
1041
defer tests.PrintCurrentTest(t)()
···
1045
1045
1046
1046
currentHeadCommitID, err := upstreamGitRepo.GetRefCommitID(pr.GetGitRefName())
1047
1047
require.NoError(t, err)
1048
-
assert.NotEqualValues(t, headCommitID, currentHeadCommitID)
1048
+
assert.NotEqual(t, headCommitID, currentHeadCommitID)
1049
1049
})
1050
1050
})
1051
1051
+5
-5
tests/integration/gpg_git_test.go
+5
-5
tests/integration/gpg_git_test.go
···
103
103
t, testCtx, user, "master", "always", "signed-always.txt", func(t *testing.T, response api.FileResponse) {
104
104
assert.NotNil(t, response.Verification)
105
105
if response.Verification == nil {
106
-
assert.FailNow(t, "no verification provided with response! %v", response)
106
+
assert.FailNow(t, "no verification provided with response", "response: %v", response)
107
107
}
108
108
assert.True(t, response.Verification.Verified)
109
109
if !response.Verification.Verified {
···
115
115
t, testCtx, user, "parentsigned", "parentsigned-always", "signed-parent2.txt", func(t *testing.T, response api.FileResponse) {
116
116
assert.NotNil(t, response.Verification)
117
117
if response.Verification == nil {
118
-
assert.FailNow(t, "no verification provided with response! %v", response)
118
+
assert.FailNow(t, "no verification provided with response", "response: %v", response)
119
119
}
120
120
assert.True(t, response.Verification.Verified)
121
121
if !response.Verification.Verified {
···
133
133
t, testCtx, user, "always", "always-parentsigned", "signed-always-parentsigned.txt", func(t *testing.T, response api.FileResponse) {
134
134
assert.NotNil(t, response.Verification)
135
135
if response.Verification == nil {
136
-
assert.FailNow(t, "no verification provided with response! %v", response)
136
+
assert.FailNow(t, "no verification provided with response", "response: %v", response)
137
137
}
138
138
assert.True(t, response.Verification.Verified)
139
139
if !response.Verification.Verified {
···
151
151
t.Run("CheckMasterBranchSigned", doAPIGetBranch(testCtx, "master", func(t *testing.T, branch api.Branch) {
152
152
assert.NotNil(t, branch.Commit)
153
153
if branch.Commit == nil {
154
-
assert.FailNow(t, "no commit provided with branch! %v", branch)
154
+
assert.FailNow(t, "no commit provided with branch", "branch: %v", branch)
155
155
}
156
156
assert.NotNil(t, branch.Commit.Verification)
157
157
if branch.Commit.Verification == nil {
158
-
assert.FailNow(t, "no verification provided with branch commit! %v", branch.Commit)
158
+
assert.FailNow(t, "no verification provided with branch commit", "commit: %v", branch.Commit)
159
159
}
160
160
assert.True(t, branch.Commit.Verification.Verified)
161
161
if !branch.Commit.Verification.Verified {
+1
-1
tests/integration/html_helper.go
+1
-1
tests/integration/html_helper.go
···
51
51
t.Helper()
52
52
53
53
options := doc.AssertDropdown(t, dropdownName).Find(".menu [data-value]:not([data-value=''])")
54
-
assert.Positive(t, options.Length(), 0, fmt.Sprintf("%s dropdown has no options", dropdownName))
54
+
assert.Positive(t, options.Length(), "%s dropdown has no options", dropdownName)
55
55
}
56
56
57
57
func (doc *HTMLDoc) AssertDropdownHasSelectedOption(t testing.TB, dropdownName, expectedValue string) {
+2
-2
tests/integration/incoming_email_test.go
+2
-2
tests/integration/incoming_email_test.go
···
52
52
ref, err := incoming_payload.GetReferenceFromPayload(db.DefaultContext, issuePayload)
53
53
require.NoError(t, err)
54
54
assert.IsType(t, ref, new(issues_model.Issue))
55
-
assert.EqualValues(t, issue.ID, ref.(*issues_model.Issue).ID)
55
+
assert.Equal(t, issue.ID, ref.(*issues_model.Issue).ID)
56
56
57
57
ref, err = incoming_payload.GetReferenceFromPayload(db.DefaultContext, commentPayload)
58
58
require.NoError(t, err)
59
59
assert.IsType(t, ref, new(issues_model.Comment))
60
-
assert.EqualValues(t, comment.ID, ref.(*issues_model.Comment).ID)
60
+
assert.Equal(t, comment.ID, ref.(*issues_model.Comment).ID)
61
61
})
62
62
63
63
t.Run("Token", func(t *testing.T) {
+3
-3
tests/integration/integration_test.go
+3
-3
tests/integration/integration_test.go
···
561
561
}
562
562
testWebRoutes.ServeHTTP(recorder, req)
563
563
if expectedStatus != NoExpectedStatus {
564
-
if !assert.EqualValues(t, expectedStatus, recorder.Code, "Request: %s %s", req.Method, req.URL.String()) {
564
+
if !assert.Equal(t, expectedStatus, recorder.Code, "Request: %s %s", req.Method, req.URL.String()) {
565
565
logUnexpectedResponse(t, recorder)
566
566
}
567
567
}
···
574
574
recorder := NewNilResponseRecorder()
575
575
testWebRoutes.ServeHTTP(recorder, req)
576
576
if expectedStatus != NoExpectedStatus {
577
-
if !assert.EqualValues(t, expectedStatus, recorder.Code,
577
+
if !assert.Equal(t, expectedStatus, recorder.Code,
578
578
"Request: %s %s", req.Method, req.URL.String()) {
579
579
logUnexpectedResponse(t, &recorder.ResponseRecorder)
580
580
}
···
588
588
recorder := NewNilResponseHashSumRecorder()
589
589
testWebRoutes.ServeHTTP(recorder, req)
590
590
if expectedStatus != NoExpectedStatus {
591
-
if !assert.EqualValues(t, expectedStatus, recorder.Code,
591
+
if !assert.Equal(t, expectedStatus, recorder.Code,
592
592
"Request: %s %s", req.Method, req.URL.String()) {
593
593
logUnexpectedResponse(t, &recorder.ResponseRecorder)
594
594
}
+4
-4
tests/integration/issue_subscribe_test.go
+4
-4
tests/integration/issue_subscribe_test.go
···
29
29
resp := session.MakeRequest(t, NewRequest(t, "GET", path.Join(testIssue)), http.StatusOK)
30
30
area := NewHTMLParser(t, resp.Body).Find(selector)
31
31
tooltip, exists := area.Attr("data-tooltip-content")
32
-
assert.EqualValues(t, unavailable, exists)
32
+
assert.Equal(t, unavailable, exists)
33
33
if unavailable {
34
-
assert.EqualValues(t, "Sign in to subscribe to this issue.", tooltip)
34
+
assert.Equal(t, "Sign in to subscribe to this issue.", tooltip)
35
35
}
36
36
37
37
resp = session.MakeRequest(t, NewRequest(t, "GET", path.Join(testPull)), http.StatusOK)
38
38
area = NewHTMLParser(t, resp.Body).Find(selector)
39
39
tooltip, exists = area.Attr("data-tooltip-content")
40
-
assert.EqualValues(t, unavailable, exists)
40
+
assert.Equal(t, unavailable, exists)
41
41
if unavailable {
42
-
assert.EqualValues(t, "Sign in to subscribe to this pull request.", tooltip)
42
+
assert.Equal(t, "Sign in to subscribe to this pull request.", tooltip)
43
43
}
44
44
}
+25
-25
tests/integration/issue_test.go
+25
-25
tests/integration/issue_test.go
···
39
39
40
40
func getIssuesSelection(t testing.TB, htmlDoc *HTMLDoc) *goquery.Selection {
41
41
issueList := htmlDoc.doc.Find("#issue-list")
42
-
assert.EqualValues(t, 1, issueList.Length())
42
+
assert.Equal(t, 1, issueList.Length())
43
43
return issueList.Find(".flex-item").Find(".issue-title")
44
44
}
45
45
···
103
103
if expectedNumIssues > setting.UI.IssuePagingNum {
104
104
expectedNumIssues = setting.UI.IssuePagingNum
105
105
}
106
-
assert.EqualValues(t, expectedNumIssues, issuesSelection.Length())
106
+
assert.Equal(t, expectedNumIssues, issuesSelection.Length())
107
107
108
108
issuesSelection.Each(func(_ int, selection *goquery.Selection) {
109
109
issue := getIssue(t, repo.ID, selection)
110
-
assert.EqualValues(t, user.ID, issue.PosterID)
110
+
assert.Equal(t, user.ID, issue.PosterID)
111
111
})
112
112
}
113
113
···
128
128
129
129
htmlDoc := NewHTMLParser(t, resp.Body)
130
130
issuesSelection := getIssuesSelection(t, htmlDoc)
131
-
assert.EqualValues(t, 1, issuesSelection.Length())
131
+
assert.Equal(t, 1, issuesSelection.Length())
132
132
issuesSelection.Each(func(_ int, selection *goquery.Selection) {
133
133
issue := getIssue(t, repo.ID, selection)
134
134
assert.False(t, issue.IsClosed)
···
142
142
resp = MakeRequest(t, req, http.StatusOK)
143
143
htmlDoc = NewHTMLParser(t, resp.Body)
144
144
issuesSelection = getIssuesSelection(t, htmlDoc)
145
-
assert.EqualValues(t, 0, issuesSelection.Length())
145
+
assert.Equal(t, 0, issuesSelection.Length())
146
146
147
147
// should match as 'first' when using a standard query
148
148
req = NewRequestf(t, "GET", "%s/issues?q=%st", repo.Link(), keyword)
149
149
resp = MakeRequest(t, req, http.StatusOK)
150
150
htmlDoc = NewHTMLParser(t, resp.Body)
151
151
issuesSelection = getIssuesSelection(t, htmlDoc)
152
-
assert.EqualValues(t, 1, issuesSelection.Length())
152
+
assert.Equal(t, 1, issuesSelection.Length())
153
153
issuesSelection.Each(func(_ int, selection *goquery.Selection) {
154
154
issue := getIssue(t, repo.ID, selection)
155
155
assert.False(t, issue.IsClosed)
···
172
172
resp := MakeRequest(t, req, http.StatusOK)
173
173
htmlDoc := NewHTMLParser(t, resp.Body)
174
174
issuesSelection := getIssuesSelection(t, htmlDoc)
175
-
assert.EqualValues(t, 3, issuesSelection.Length())
175
+
assert.Equal(t, 3, issuesSelection.Length())
176
176
})
177
177
178
178
t.Run("Issues with no project", func(t *testing.T) {
···
180
180
resp := MakeRequest(t, req, http.StatusOK)
181
181
htmlDoc := NewHTMLParser(t, resp.Body)
182
182
issuesSelection := getIssuesSelection(t, htmlDoc)
183
-
assert.EqualValues(t, 1, issuesSelection.Length())
183
+
assert.Equal(t, 1, issuesSelection.Length())
184
184
issuesSelection.Each(func(_ int, selection *goquery.Selection) {
185
185
issue := getIssue(t, repo.ID, selection)
186
186
assert.Equal(t, issueNoProject.ID, issue.ID)
···
194
194
resp := MakeRequest(t, req, http.StatusOK)
195
195
htmlDoc := NewHTMLParser(t, resp.Body)
196
196
issuesSelection := getIssuesSelection(t, htmlDoc)
197
-
assert.EqualValues(t, 2, issuesSelection.Length())
197
+
assert.Equal(t, 2, issuesSelection.Length())
198
198
found := map[int64]bool{
199
199
1: false,
200
200
5: false,
···
389
389
390
390
if hasDependency {
391
391
assert.NotEmpty(t, issues)
392
-
assert.EqualValues(t, issues[0].Index, dependencyID)
392
+
assert.Equal(t, issues[0].Index, dependencyID)
393
393
} else {
394
394
assert.Empty(t, issues)
395
395
}
···
569
569
session.MakeRequest(t, req, http.StatusOK)
570
570
571
571
comment = unittest.AssertExistsAndLoadBean(t, &issues_model.Comment{ID: commentID})
572
-
assert.Equal(t, "", comment.Content)
572
+
assert.Empty(t, comment.Content)
573
573
}
574
574
575
575
func TestIssueCommentUpdateSimultaneously(t *testing.T) {
···
798
798
req = NewRequest(t, "GET", link.String())
799
799
resp = session.MakeRequest(t, req, http.StatusOK)
800
800
DecodeJSON(t, resp, &apiIssues)
801
-
assert.EqualValues(t, "22", resp.Header().Get("X-Total-Count"))
801
+
assert.Equal(t, "22", resp.Header().Get("X-Total-Count"))
802
802
assert.Len(t, apiIssues, 20)
803
803
804
804
query.Add("limit", "5")
···
806
806
req = NewRequest(t, "GET", link.String())
807
807
resp = session.MakeRequest(t, req, http.StatusOK)
808
808
DecodeJSON(t, resp, &apiIssues)
809
-
assert.EqualValues(t, "22", resp.Header().Get("X-Total-Count"))
809
+
assert.Equal(t, "22", resp.Header().Get("X-Total-Count"))
810
810
assert.Len(t, apiIssues, 5)
811
811
812
812
query = url.Values{"assigned": {"true"}, "state": {"all"}}
···
930
930
var apiIssue api.Issue
931
931
DecodeJSON(t, resp, &apiIssue)
932
932
933
-
assert.EqualValues(t, issue.ID, apiIssue.ID)
933
+
assert.Equal(t, issue.ID, apiIssue.ID)
934
934
}
935
935
936
936
func TestIssuePinMove(t *testing.T) {
937
937
defer tests.PrepareTestEnv(t)()
938
938
session := loginUser(t, "user2")
939
939
issueURL, issue := testIssueWithBean(t, "user2", 1, "Title", "Content")
940
-
assert.EqualValues(t, 0, issue.PinOrder)
940
+
assert.Equal(t, 0, issue.PinOrder)
941
941
942
942
req := NewRequestWithValues(t, "POST", fmt.Sprintf("%s/pin", issueURL), map[string]string{
943
943
"_csrf": GetCSRF(t, session, issueURL),
···
946
946
issue = unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: issue.ID})
947
947
948
948
position := 1
949
-
assert.EqualValues(t, position, issue.PinOrder)
949
+
assert.Equal(t, position, issue.PinOrder)
950
950
951
951
newPosition := 2
952
952
···
961
961
session5.MakeRequest(t, req, http.StatusNotFound)
962
962
963
963
issue = unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: issue.ID})
964
-
assert.EqualValues(t, position, issue.PinOrder)
964
+
assert.Equal(t, position, issue.PinOrder)
965
965
}
966
966
967
967
movePinURL := issueURL[:strings.LastIndexByte(issueURL, '/')] + "/move_pin?_csrf=" + GetCSRF(t, session, issueURL)
···
972
972
session.MakeRequest(t, req, http.StatusNoContent)
973
973
974
974
issue = unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: issue.ID})
975
-
assert.EqualValues(t, newPosition, issue.PinOrder)
975
+
assert.Equal(t, newPosition, issue.PinOrder)
976
976
}
977
977
978
978
func TestUpdateIssueDeadline(t *testing.T) {
···
1001
1001
var apiIssue api.IssueDeadline
1002
1002
DecodeJSON(t, resp, &apiIssue)
1003
1003
1004
-
assert.EqualValues(t, "2022-04-06", apiIssue.Deadline.Format("2006-01-02"))
1004
+
assert.Equal(t, "2022-04-06", apiIssue.Deadline.Format("2006-01-02"))
1005
1005
}
1006
1006
1007
1007
func TestUpdateIssueTitle(t *testing.T) {
···
1059
1059
}{}
1060
1060
1061
1061
DecodeJSON(t, resp, &issueAfter)
1062
-
assert.EqualValues(t, issueTitleUpdateTest.title, issueAfter.Title)
1062
+
assert.Equal(t, issueTitleUpdateTest.title, issueAfter.Title)
1063
1063
}
1064
1064
}
1065
1065
}
···
1077
1077
1078
1078
// the "reference" uses relative URLs, then JS code will convert them to absolute URLs for current origin, in case users are using multiple domains
1079
1079
ref, _ := htmlDoc.Find(`.timeline-item.comment.first .reference-issue`).Attr("data-reference")
1080
-
assert.EqualValues(t, "/user2/repo1/issues/1#issue-1", ref)
1080
+
assert.Equal(t, "/user2/repo1/issues/1#issue-1", ref)
1081
1081
1082
1082
ref, _ = htmlDoc.Find(`.timeline-item.comment:not(.first) .reference-issue`).Attr("data-reference")
1083
-
assert.EqualValues(t, "/user2/repo1/issues/1#issuecomment-2", ref)
1083
+
assert.Equal(t, "/user2/repo1/issues/1#issuecomment-2", ref)
1084
1084
}
1085
1085
1086
1086
func TestGetContentHistory(t *testing.T) {
···
1109
1109
var respJSON contentHistoryResp
1110
1110
DecodeJSON(t, resp, &respJSON)
1111
1111
1112
-
assert.EqualValues(t, canDelete, respJSON.CanSoftDelete)
1112
+
assert.Equal(t, canDelete, respJSON.CanSoftDelete)
1113
1113
assert.EqualValues(t, contentHistory.ID, respJSON.HistoryID)
1114
1114
assert.EqualValues(t, contentHistory.ID-1, respJSON.PrevHistoryID)
1115
1115
}
···
1357
1357
DecodeJSON(t, resp, &data)
1358
1358
1359
1359
assert.Len(t, data.Results, 1)
1360
-
assert.EqualValues(t, "user2", data.Results[0].UserName)
1360
+
assert.Equal(t, "user2", data.Results[0].UserName)
1361
1361
assert.EqualValues(t, 2, data.Results[0].UserID)
1362
1362
})
1363
1363
···
1372
1372
DecodeJSON(t, resp, &data)
1373
1373
1374
1374
assert.Len(t, data.Results, 1)
1375
-
assert.EqualValues(t, "user1", data.Results[0].UserName)
1375
+
assert.Equal(t, "user1", data.Results[0].UserName)
1376
1376
assert.EqualValues(t, 1, data.Results[0].UserID)
1377
1377
})
1378
1378
}
+2
-2
tests/integration/links_test.go
+2
-2
tests/integration/links_test.go
···
60
60
for link, redirectLink := range redirects {
61
61
req := NewRequest(t, "GET", link)
62
62
resp := MakeRequest(t, req, http.StatusSeeOther)
63
-
assert.EqualValues(t, path.Join(setting.AppSubURL, redirectLink), test.RedirectURL(resp))
63
+
assert.Equal(t, path.Join(setting.AppSubURL, redirectLink), test.RedirectURL(resp))
64
64
}
65
65
}
66
66
···
195
195
for _, info := range redirects {
196
196
req := NewRequest(t, info.verb, info.from)
197
197
resp := MakeRequest(t, req, http.StatusSeeOther)
198
-
assert.EqualValues(t, path.Join(setting.AppSubURL, info.to), test.RedirectURL(resp), info.from)
198
+
assert.Equal(t, path.Join(setting.AppSubURL, info.to), test.RedirectURL(resp), info.from)
199
199
}
200
200
}
201
201
+2
-2
tests/integration/markup_external_test.go
+2
-2
tests/integration/markup_external_test.go
···
27
27
const repoURL = "user30/renderer"
28
28
req := NewRequest(t, "GET", repoURL+"/src/branch/master/README.html")
29
29
resp := MakeRequest(t, req, http.StatusOK)
30
-
assert.EqualValues(t, "text/html; charset=utf-8", resp.Header()["Content-Type"][0])
30
+
assert.Equal(t, "text/html; charset=utf-8", resp.Header()["Content-Type"][0])
31
31
32
32
bs, err := io.ReadAll(resp.Body)
33
33
require.NoError(t, err)
···
36
36
div := doc.Find("div.file-view")
37
37
data, err := div.Html()
38
38
require.NoError(t, err)
39
-
assert.EqualValues(t, "<div>\n\ttest external renderer\n</div>", strings.TrimSpace(data))
39
+
assert.Equal(t, "<div>\n\ttest external renderer\n</div>", strings.TrimSpace(data))
40
40
}
+3
-3
tests/integration/migrate_test.go
+3
-3
tests/integration/migrate_test.go
···
106
106
})
107
107
resp = session.MakeRequest(t, req, http.StatusSeeOther)
108
108
// Step 5: a redirection displays the migrated repository
109
-
assert.EqualValues(t, fmt.Sprintf("/%s/%s", ownerName, migratedRepoName), test.RedirectURL(resp))
109
+
assert.Equal(t, fmt.Sprintf("/%s/%s", ownerName, migratedRepoName), test.RedirectURL(resp))
110
110
// Step 6: check the repo was created
111
111
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{Name: migratedRepoName})
112
112
})
···
163
163
})
164
164
resp = session.MakeRequest(t, req, http.StatusSeeOther)
165
165
// Step 5: a redirection displays the migrated repository
166
-
assert.EqualValues(t, fmt.Sprintf("/%s/%s", user.Name, migratedRepoName), test.RedirectURL(resp))
166
+
assert.Equal(t, fmt.Sprintf("/%s/%s", user.Name, migratedRepoName), test.RedirectURL(resp))
167
167
// Step 6: check the repo was created and load the repo
168
168
migratedRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{Name: migratedRepoName, WikiBranch: "obscure-name"})
169
169
// Step 7: check if the wiki is enabled
···
219
219
})
220
220
resp = session.MakeRequest(t, req, http.StatusSeeOther)
221
221
// Step 5: a redirection displays the migrated repository
222
-
assert.EqualValues(t, fmt.Sprintf("/%s/%s", ownerName, migratedRepoName), test.RedirectURL(resp))
222
+
assert.Equal(t, fmt.Sprintf("/%s/%s", ownerName, migratedRepoName), test.RedirectURL(resp))
223
223
// Step 6: check the repo was created and load the repo
224
224
migratedRepo := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{Name: migratedRepoName})
225
225
// Step 7: check if releases are enabled
+2
-2
tests/integration/mirror_pull_test.go
+2
-2
tests/integration/mirror_pull_test.go
···
88
88
89
89
count, err := db.Count[repo_model.Release](db.DefaultContext, findOptions)
90
90
require.NoError(t, err)
91
-
assert.EqualValues(t, initCount+1, count)
91
+
assert.Equal(t, initCount+1, count)
92
92
93
93
release, err := repo_model.GetRelease(db.DefaultContext, repo.ID, "v0.2")
94
94
require.NoError(t, err)
···
99
99
100
100
count, err = db.Count[repo_model.Release](db.DefaultContext, findOptions)
101
101
require.NoError(t, err)
102
-
assert.EqualValues(t, initCount, count)
102
+
assert.Equal(t, initCount, count)
103
103
}
+1
-1
tests/integration/mirror_push_test.go
+1
-1
tests/integration/mirror_push_test.go
···
261
261
htmlDoc := NewHTMLParser(t, resp.Body)
262
262
263
263
publickey = htmlDoc.Find(".ui.table td a[data-clipboard-text]").AttrOr("data-clipboard-text", "")
264
-
assert.EqualValues(t, publickey, pushMirror.GetPublicKey())
264
+
assert.Equal(t, publickey, pushMirror.GetPublicKey())
265
265
})
266
266
267
267
t.Run("Add deploy key", func(t *testing.T) {
+1
-1
tests/integration/new_org_test.go
+1
-1
tests/integration/new_org_test.go
+1
-1
tests/integration/oauth_test.go
+1
-1
tests/integration/oauth_test.go
+1
-1
tests/integration/opengraph_test.go
+1
-1
tests/integration/opengraph_test.go
+1
-1
tests/integration/org_test.go
+1
-1
tests/integration/org_test.go
+5
-5
tests/integration/private_project_test.go
+5
-5
tests/integration/private_project_test.go
···
48
48
htmlDoc = NewHTMLParser(t, resp.Body)
49
49
issueCardsLen := htmlDoc.Find(".project-column .issue-card").Length()
50
50
if hasAccess {
51
-
assert.EqualValues(t, 2, issueCardsLen)
51
+
assert.Equal(t, 2, issueCardsLen)
52
52
} else {
53
-
assert.EqualValues(t, 1, issueCardsLen)
53
+
assert.Equal(t, 1, issueCardsLen)
54
54
// Ensure that the public issue is shown.
55
-
assert.EqualValues(t, publicIssueHref[0], htmlDoc.Find(".project-column .issue-card .issue-card-title").AttrOr("href", ""))
55
+
assert.Equal(t, publicIssueHref[0], htmlDoc.Find(".project-column .issue-card .issue-card-title").AttrOr("href", ""))
56
56
}
57
57
58
58
// And that the issue count is correct.
59
59
issueCount := strings.TrimSpace(htmlDoc.Find(".project-column-issue-count").Text())
60
60
if hasAccess {
61
-
assert.EqualValues(t, "2", issueCount)
61
+
assert.Equal(t, "2", issueCount)
62
62
} else {
63
-
assert.EqualValues(t, "1", issueCount)
63
+
assert.Equal(t, "1", issueCount)
64
64
}
65
65
}
66
66
+3
-3
tests/integration/project_test.go
+3
-3
tests/integration/project_test.go
···
76
76
columnsAfter, err := project1.GetColumns(db.DefaultContext)
77
77
require.NoError(t, err)
78
78
assert.Len(t, columns, 3)
79
-
assert.EqualValues(t, columns[1].ID, columnsAfter[0].ID)
80
-
assert.EqualValues(t, columns[2].ID, columnsAfter[1].ID)
81
-
assert.EqualValues(t, columns[0].ID, columnsAfter[2].ID)
79
+
assert.Equal(t, columns[1].ID, columnsAfter[0].ID)
80
+
assert.Equal(t, columns[2].ID, columnsAfter[1].ID)
81
+
assert.Equal(t, columns[0].ID, columnsAfter[2].ID)
82
82
83
83
require.NoError(t, project_model.DeleteProjectByID(db.DefaultContext, project1.ID))
84
84
}
+1
-1
tests/integration/pull_compare_test.go
+1
-1
tests/integration/pull_compare_test.go
+4
-4
tests/integration/pull_create_test.go
+4
-4
tests/integration/pull_create_test.go
···
539
539
540
540
respChildPR := testPullCreateDirectly(t, session, "user2", "repo1", "master", "user1", "repo1", "recent-push", "Child Pull Request")
541
541
elemChildPR := strings.Split(test.RedirectURL(respChildPR), "/")
542
-
assert.EqualValues(t, "user2", elemChildPR[1])
543
-
assert.EqualValues(t, "repo1", elemChildPR[2])
544
-
assert.EqualValues(t, "pulls", elemChildPR[3])
542
+
assert.Equal(t, "user2", elemChildPR[1])
543
+
assert.Equal(t, "repo1", elemChildPR[2])
544
+
assert.Equal(t, "pulls", elemChildPR[3])
545
545
session2 := loginUser(t, "user2")
546
546
// Merge the PR from the fork
547
547
testPullMerge(t, session2, elemChildPR[1], elemChildPR[2], elemChildPR[4], repo_model.MergeStyleSquash, false)
548
548
549
549
respBasePR := testPullCreate(t, session, "user2", "repo1", true, "master", "recent-push-base", "Base Pull Request")
550
550
elemBasePR := strings.Split(test.RedirectURL(respBasePR), "/")
551
-
assert.EqualValues(t, "pulls", elemBasePR[3])
551
+
assert.Equal(t, "pulls", elemBasePR[3])
552
552
// Leave the PR from the base repo open (it conflicts with the PR from the fork anyway)
553
553
554
554
// Count recently pushed branches on the base repo
+19
-19
tests/integration/pull_merge_test.go
+19
-19
tests/integration/pull_merge_test.go
···
84
84
}{}
85
85
DecodeJSON(t, resp, &respJSON)
86
86
87
-
assert.EqualValues(t, fmt.Sprintf("/%s/%s/pulls/%s", user, repo, pullnum), respJSON.Redirect)
87
+
assert.Equal(t, fmt.Sprintf("/%s/%s/pulls/%s", user, repo, pullnum), respJSON.Redirect)
88
88
}
89
89
90
90
return resp
···
144
144
resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title")
145
145
146
146
elem := strings.Split(test.RedirectURL(resp), "/")
147
-
assert.EqualValues(t, "pulls", elem[3])
147
+
assert.Equal(t, "pulls", elem[3])
148
148
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge, false)
149
149
150
150
hookTasks = retrieveHookTasks(t, 1, false)
···
164
164
resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title")
165
165
166
166
elem := strings.Split(test.RedirectURL(resp), "/")
167
-
assert.EqualValues(t, "pulls", elem[3])
167
+
assert.Equal(t, "pulls", elem[3])
168
168
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleRebase, false)
169
169
170
170
hookTasks = retrieveHookTasks(t, 1, false)
···
184
184
resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title")
185
185
186
186
elem := strings.Split(test.RedirectURL(resp), "/")
187
-
assert.EqualValues(t, "pulls", elem[3])
187
+
assert.Equal(t, "pulls", elem[3])
188
188
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleRebaseMerge, false)
189
189
190
190
hookTasks = retrieveHookTasks(t, 1, false)
···
205
205
resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title")
206
206
207
207
elem := strings.Split(test.RedirectURL(resp), "/")
208
-
assert.EqualValues(t, "pulls", elem[3])
208
+
assert.Equal(t, "pulls", elem[3])
209
209
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleSquash, false)
210
210
211
211
hookTasks = retrieveHookTasks(t, 1, false)
···
222
222
resp := testPullCreate(t, session, "user1", "repo1", false, "master", "feature/test", "This is a pull title")
223
223
224
224
elem := strings.Split(test.RedirectURL(resp), "/")
225
-
assert.EqualValues(t, "pulls", elem[3])
225
+
assert.Equal(t, "pulls", elem[3])
226
226
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge, false)
227
227
228
228
// Check PR branch deletion
···
235
235
assert.NotEmpty(t, respJSON.Redirect, "Redirected URL is not found")
236
236
237
237
elem = strings.Split(respJSON.Redirect, "/")
238
-
assert.EqualValues(t, "pulls", elem[3])
238
+
assert.Equal(t, "pulls", elem[3])
239
239
240
240
// Check branch deletion result
241
241
req := NewRequest(t, "GET", respJSON.Redirect)
···
244
244
htmlDoc := NewHTMLParser(t, resp.Body)
245
245
resultMsg := htmlDoc.doc.Find(".ui.message>p").Text()
246
246
247
-
assert.EqualValues(t, "Branch \"user1/repo1:feature/test\" has been deleted.", resultMsg)
247
+
assert.Equal(t, "Branch \"user1/repo1:feature/test\" has been deleted.", resultMsg)
248
248
})
249
249
}
250
250
···
573
573
574
574
respBasePR := testPullCreate(t, session, "user2", "repo1", true, "master", "base-pr", "Base Pull Request")
575
575
elemBasePR := strings.Split(test.RedirectURL(respBasePR), "/")
576
-
assert.EqualValues(t, "pulls", elemBasePR[3])
576
+
assert.Equal(t, "pulls", elemBasePR[3])
577
577
578
578
respChildPR := testPullCreate(t, session, "user1", "repo1", false, "base-pr", "child-pr", "Child Pull Request")
579
579
elemChildPR := strings.Split(test.RedirectURL(respChildPR), "/")
580
-
assert.EqualValues(t, "pulls", elemChildPR[3])
580
+
assert.Equal(t, "pulls", elemChildPR[3])
581
581
582
582
testPullMerge(t, session, elemBasePR[1], elemBasePR[2], elemBasePR[4], repo_model.MergeStyleMerge, true)
583
583
···
589
589
targetBranch := htmlDoc.doc.Find("#branch_target>a").Text()
590
590
prStatus := strings.TrimSpace(htmlDoc.doc.Find(".issue-title-meta>.issue-state-label").Text())
591
591
592
-
assert.EqualValues(t, "master", targetBranch)
593
-
assert.EqualValues(t, "Open", prStatus)
592
+
assert.Equal(t, "master", targetBranch)
593
+
assert.Equal(t, "Open", prStatus)
594
594
})
595
595
}
596
596
···
603
603
604
604
respBasePR := testPullCreate(t, session, "user1", "repo1", false, "master", "base-pr", "Base Pull Request")
605
605
elemBasePR := strings.Split(test.RedirectURL(respBasePR), "/")
606
-
assert.EqualValues(t, "pulls", elemBasePR[3])
606
+
assert.Equal(t, "pulls", elemBasePR[3])
607
607
608
608
respChildPR := testPullCreate(t, session, "user1", "repo1", true, "base-pr", "child-pr", "Child Pull Request")
609
609
elemChildPR := strings.Split(test.RedirectURL(respChildPR), "/")
610
-
assert.EqualValues(t, "pulls", elemChildPR[3])
610
+
assert.Equal(t, "pulls", elemChildPR[3])
611
611
612
612
testPullMerge(t, session, elemBasePR[1], elemBasePR[2], elemBasePR[4], repo_model.MergeStyleMerge, true)
613
613
···
619
619
targetBranch := htmlDoc.doc.Find("#branch_target>a").Text()
620
620
prStatus := strings.TrimSpace(htmlDoc.doc.Find(".issue-title-meta>.issue-state-label").Text())
621
621
622
-
assert.EqualValues(t, "base-pr", targetBranch)
623
-
assert.EqualValues(t, "Closed", prStatus)
622
+
assert.Equal(t, "base-pr", targetBranch)
623
+
assert.Equal(t, "Closed", prStatus)
624
624
})
625
625
}
626
626
···
662
662
663
663
// merge the pull request
664
664
elem := strings.Split(test.RedirectURL(createPullResp), "/")
665
-
assert.EqualValues(t, "pulls", elem[3])
665
+
assert.Equal(t, "pulls", elem[3])
666
666
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge, false)
667
667
668
668
// check if the issue is closed
···
696
696
defer repo.Close()
697
697
id, err := repo.GetBranchCommitID(branch)
698
698
require.NoError(t, err)
699
-
assert.EqualValues(t, commitID, id)
699
+
assert.Equal(t, commitID, id)
700
700
}
701
701
702
702
func TestPullMergeBranchProtect(t *testing.T) {
···
1186
1186
1187
1187
flashCookie := user4Session.GetCookie(forgejo_context.CookieNameFlash)
1188
1188
assert.NotNil(t, flashCookie)
1189
-
assert.EqualValues(t, "error%3DYou%2Bdon%2527t%2Bhave%2Bpermission%2Bto%2Bdelete%2Bthe%2Bhead%2Bbranch.", flashCookie.Value)
1189
+
assert.Equal(t, "error%3DYou%2Bdon%2527t%2Bhave%2Bpermission%2Bto%2Bdelete%2Bthe%2Bhead%2Bbranch.", flashCookie.Value)
1190
1190
1191
1191
// Check that the branch still exist.
1192
1192
req = NewRequest(t, "GET", "/user2/repo1/src/branch/base-pr")
+7
-7
tests/integration/pull_review_test.go
+7
-7
tests/integration/pull_review_test.go
···
109
109
resp := testPullCreate(t, user2Session, "user2", "test_reviewer", false, repo.DefaultBranch, "codeowner-basebranch", "Test Pull Request")
110
110
prURL := test.RedirectURL(resp)
111
111
elem := strings.Split(prURL, "/")
112
-
assert.EqualValues(t, "pulls", elem[3])
112
+
assert.Equal(t, "pulls", elem[3])
113
113
114
114
req := NewRequest(t, http.MethodGet, prURL)
115
115
resp = MakeRequest(t, req, http.StatusOK)
···
390
390
require.NoError(t, err)
391
391
prUpdated1 := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: pr.ID})
392
392
require.NoError(t, prUpdated1.LoadIssue(db.DefaultContext))
393
-
assert.EqualValues(t, "[WIP] Test Pull Request", prUpdated1.Issue.Title)
393
+
assert.Equal(t, "[WIP] Test Pull Request", prUpdated1.Issue.Title)
394
394
395
395
err = issue_service.ChangeTitle(db.DefaultContext, prUpdated1.Issue, user2, "Test Pull Request2")
396
396
require.NoError(t, err)
397
397
prUpdated2 := unittest.AssertExistsAndLoadBean(t, &issues_model.PullRequest{ID: pr.ID})
398
398
require.NoError(t, prUpdated2.LoadIssue(db.DefaultContext))
399
-
assert.EqualValues(t, "Test Pull Request2", prUpdated2.Issue.Title)
399
+
assert.Equal(t, "Test Pull Request2", prUpdated2.Issue.Title)
400
400
})
401
401
402
402
// change the default branch CODEOWNERS file to change README.md's codeowner
···
496
496
testEditFile(t, user1Session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
497
497
resp := testPullCreate(t, user1Session, "user1", "repo1", false, "master", "master", "This is a pull title")
498
498
elem := strings.Split(test.RedirectURL(resp), "/")
499
-
assert.EqualValues(t, "pulls", elem[3])
499
+
assert.Equal(t, "pulls", elem[3])
500
500
testPullMerge(t, user1Session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge, false)
501
501
502
502
// Get the commit SHA
···
528
528
testEditFileToNewBranch(t, user1Session, "user1", "repo1", "master", "a-test-branch", "README.md", "Hello, World (Edited...again)\n")
529
529
resp := testPullCreate(t, user1Session, "user1", "repo1", false, "master", "a-test-branch", "This is a pull title")
530
530
elem := strings.Split(test.RedirectURL(resp), "/")
531
-
assert.EqualValues(t, "pulls", elem[3])
531
+
assert.Equal(t, "pulls", elem[3])
532
532
testIssueClose(t, user1Session, elem[1], elem[2], elem[4], true)
533
533
534
534
// Get the commit SHA
···
713
713
defer test.MockVariableValue(&mailer.SendAsync, func(msgs ...*mailer.Message) {
714
714
assert.Len(t, msgs, 2)
715
715
assert.Equal(t, "user1@example.com", msgs[0].To)
716
-
assert.EqualValues(t, "Re: [user2/repo1] issue2 (PR #2)", msgs[0].Subject)
716
+
assert.Equal(t, "Re: [user2/repo1] issue2 (PR #2)", msgs[0].Subject)
717
717
assert.Contains(t, msgs[0].Body, "Notification time!")
718
718
called = true
719
719
})()
···
741
741
defer test.MockVariableValue(&mailer.SendAsync, func(msgs ...*mailer.Message) {
742
742
assert.Len(t, msgs, 2)
743
743
assert.Equal(t, "user1@example.com", msgs[0].To)
744
-
assert.EqualValues(t, "Re: [user2/repo1] issue2 (PR #2)", msgs[0].Subject)
744
+
assert.Equal(t, "Re: [user2/repo1] issue2 (PR #2)", msgs[0].Subject)
745
745
assert.Contains(t, msgs[0].Body, "Notification time 2!")
746
746
called = true
747
747
})()
+2
-2
tests/integration/pull_status_test.go
+2
-2
tests/integration/pull_status_test.go
···
86
86
commitURL, exists = doc.doc.Find("#commits-table tbody tr td.sha a").Last().Attr("href")
87
87
assert.True(t, exists)
88
88
assert.NotEmpty(t, commitURL)
89
-
assert.EqualValues(t, commitID, path.Base(commitURL))
89
+
assert.Equal(t, commitID, path.Base(commitURL))
90
90
91
91
cls, ok := doc.doc.Find("#commits-table tbody tr td.message .commit-status").Last().Attr("class")
92
92
assert.True(t, ok)
···
95
95
96
96
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerName: "user1", Name: "repo1"})
97
97
css := unittest.AssertExistsAndLoadBean(t, &git_model.CommitStatusSummary{RepoID: repo1.ID, SHA: commitID})
98
-
assert.EqualValues(t, api.CommitStatusWarning, css.State)
98
+
assert.Equal(t, api.CommitStatusWarning, css.State)
99
99
})
100
100
}
101
101
+12
-12
tests/integration/pull_update_test.go
+12
-12
tests/integration/pull_update_test.go
···
39
39
// Test GetDiverging
40
40
diffCount, err := pull_service.GetDiverging(git.DefaultContext, pr)
41
41
require.NoError(t, err)
42
-
assert.EqualValues(t, 1, diffCount.Behind)
43
-
assert.EqualValues(t, 1, diffCount.Ahead)
42
+
assert.Equal(t, 1, diffCount.Behind)
43
+
assert.Equal(t, 1, diffCount.Ahead)
44
44
require.NoError(t, pr.LoadBaseRepo(db.DefaultContext))
45
45
require.NoError(t, pr.LoadIssue(db.DefaultContext))
46
46
···
53
53
// Test GetDiverging after update
54
54
diffCount, err = pull_service.GetDiverging(git.DefaultContext, pr)
55
55
require.NoError(t, err)
56
-
assert.EqualValues(t, 0, diffCount.Behind)
57
-
assert.EqualValues(t, 2, diffCount.Ahead)
56
+
assert.Equal(t, 0, diffCount.Behind)
57
+
assert.Equal(t, 2, diffCount.Ahead)
58
58
})
59
59
}
60
60
···
68
68
// Test GetDiverging
69
69
diffCount, err := pull_service.GetDiverging(git.DefaultContext, pr)
70
70
require.NoError(t, err)
71
-
assert.EqualValues(t, 1, diffCount.Behind)
72
-
assert.EqualValues(t, 1, diffCount.Ahead)
71
+
assert.Equal(t, 1, diffCount.Behind)
72
+
assert.Equal(t, 1, diffCount.Ahead)
73
73
require.NoError(t, pr.LoadBaseRepo(db.DefaultContext))
74
74
require.NoError(t, pr.LoadIssue(db.DefaultContext))
75
75
···
82
82
// Test GetDiverging after update
83
83
diffCount, err = pull_service.GetDiverging(git.DefaultContext, pr)
84
84
require.NoError(t, err)
85
-
assert.EqualValues(t, 0, diffCount.Behind)
86
-
assert.EqualValues(t, 1, diffCount.Ahead)
85
+
assert.Equal(t, 0, diffCount.Behind)
86
+
assert.Equal(t, 1, diffCount.Ahead)
87
87
})
88
88
}
89
89
···
98
98
// Test GetDiverging
99
99
diffCount, err := pull_service.GetDiverging(git.DefaultContext, pr)
100
100
require.NoError(t, err)
101
-
assert.EqualValues(t, 1, diffCount.Behind)
102
-
assert.EqualValues(t, 1, diffCount.Ahead)
101
+
assert.Equal(t, 1, diffCount.Behind)
102
+
assert.Equal(t, 1, diffCount.Ahead)
103
103
require.NoError(t, pr.LoadBaseRepo(db.DefaultContext))
104
104
require.NoError(t, pr.LoadIssue(db.DefaultContext))
105
105
···
145
145
// Test GetDiverging
146
146
diffCount, err := pull_service.GetDiverging(git.DefaultContext, pr)
147
147
require.NoError(t, err)
148
-
assert.EqualValues(t, 1, diffCount.Behind)
149
-
assert.EqualValues(t, 1, diffCount.Ahead)
148
+
assert.Equal(t, 1, diffCount.Behind)
149
+
assert.Equal(t, 1, diffCount.Ahead)
150
150
require.NoError(t, pr.LoadBaseRepo(db.DefaultContext))
151
151
require.NoError(t, pr.LoadIssue(db.DefaultContext))
152
152
+1
-1
tests/integration/quota_use_test.go
+1
-1
tests/integration/quota_use_test.go
···
697
697
htmlDoc := NewHTMLParser(ctx.t, ctx.response.Body)
698
698
flashMessage := strings.TrimSpace(htmlDoc.Find(`.flash-message`).Text())
699
699
700
-
assert.EqualValues(ctx.t, value, flashMessage)
700
+
assert.Equal(ctx.t, value, flashMessage)
701
701
}
702
702
703
703
func (ctx *quotaWebEnvAsContext) ExpectFlashMessageContains(parts ...string) {
+2
-2
tests/integration/release_feed_test.go
+2
-2
tests/integration/release_feed_test.go
···
28
28
defer tests.PrintCurrentTest(t)()
29
29
30
30
resp := MakeRequest(t, NewRequest(t, "GET", "/user2/repo1/releases.rss"), http.StatusOK)
31
-
assert.EqualValues(t, `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
31
+
assert.Equal(t, `<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/">
32
32
<channel>
33
33
<title>Releases for user2/repo1</title>
34
34
<link>http://localhost/user2/repo1/release</link>
···
60
60
defer tests.PrintCurrentTest(t)()
61
61
62
62
resp := MakeRequest(t, NewRequest(t, "GET", "/user2/repo1/releases.atom"), http.StatusOK)
63
-
assert.EqualValues(t, `<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
63
+
assert.Equal(t, `<?xml version="1.0" encoding="UTF-8"?><feed xmlns="http://www.w3.org/2005/Atom">
64
64
<title>Releases for user2/repo1</title>
65
65
<id>http://localhost/user2/repo1/release</id>
66
66
<updated></updated>
+10
-10
tests/integration/release_test.go
+10
-10
tests/integration/release_test.go
···
64
64
65
65
htmlDoc := NewHTMLParser(t, resp.Body)
66
66
labelText := htmlDoc.doc.Find("#release-list > li .detail .label").First().Text()
67
-
assert.EqualValues(t, label, labelText)
67
+
assert.Equal(t, label, labelText)
68
68
titleText := htmlDoc.doc.Find("#release-list > li .detail h4 a").First().Text()
69
-
assert.EqualValues(t, version, titleText)
69
+
assert.Equal(t, version, titleText)
70
70
71
71
// Check release count in the counter on the Release/Tag switch, as well as that the tab is highlighted
72
72
if count < 10 { // Only check values less than 10, should be enough attempts before this test cracks
···
76
76
}
77
77
78
78
releaseList := htmlDoc.doc.Find("#release-list > li")
79
-
assert.EqualValues(t, count, releaseList.Length())
79
+
assert.Equal(t, count, releaseList.Length())
80
80
}
81
81
82
82
func TestViewReleases(t *testing.T) {
···
212
212
commitsToMain = append(commitsToMain, s.Find(".ahead > a").Text())
213
213
})
214
214
215
-
assert.EqualValues(t, []string{
215
+
assert.Equal(t, []string{
216
216
"/user2/repo-release/releases/tag/empty-target-branch",
217
217
"/user2/repo-release/releases/tag/non-existing-target-branch",
218
218
"/user2/repo-release/releases/tag/v2.0",
219
219
"/user2/repo-release/releases/tag/v1.1",
220
220
"/user2/repo-release/releases/tag/v1.0",
221
221
}, links)
222
-
assert.EqualValues(t, []string{
222
+
assert.Equal(t, []string{
223
223
"1 commits", // like v1.1
224
224
"1 commits", // like v1.1
225
225
"0 commits",
···
237
237
htmlDoc := NewHTMLParser(t, resp.Body)
238
238
// check the "number of commits to main since this release"
239
239
releaseList := htmlDoc.doc.Find("#release-list .ahead > a")
240
-
assert.EqualValues(t, 1, releaseList.Length())
241
-
assert.EqualValues(t, "3 commits", releaseList.First().Text())
240
+
assert.Equal(t, 1, releaseList.Length())
241
+
assert.Equal(t, "3 commits", releaseList.First().Text())
242
242
}
243
243
244
244
func TestViewReleaseListLogin(t *testing.T) {
···
265
265
links = append(links, link)
266
266
})
267
267
268
-
assert.EqualValues(t, []string{
268
+
assert.Equal(t, []string{
269
269
"/user2/repo1/releases/tag/draft-release",
270
270
"/user2/repo1/releases/tag/v1.0",
271
271
"/user2/repo1/releases/tag/v1.1",
···
296
296
links = append(links, link)
297
297
})
298
298
299
-
assert.EqualValues(t, []string{
299
+
assert.Equal(t, []string{
300
300
"/user2/repo1/releases/tag/v1.1",
301
301
}, links)
302
302
}
···
330
330
tagNames = append(tagNames, s.Find(".tag a.tw-flex.tw-items-center").Text())
331
331
})
332
332
333
-
assert.EqualValues(t, []string{"v1.0", "delete-tag", "v1.1"}, tagNames)
333
+
assert.Equal(t, []string{"v1.0", "delete-tag", "v1.1"}, tagNames)
334
334
}
335
335
336
336
func TestDownloadReleaseAttachment(t *testing.T) {
+1
-1
tests/integration/remote_test.go
+1
-1
tests/integration/remote_test.go
···
73
73
assert.Equal(t, auth_model.Remote, userBeforeSignIn.LoginType)
74
74
assert.Equal(t, auth_model.OAuth2, userAfterSignIn.LoginType)
75
75
// the OAuth2 email was used to set the missing user email
76
-
assert.Equal(t, "", userBeforeSignIn.Email)
76
+
assert.Empty(t, userBeforeSignIn.Email)
77
77
assert.Equal(t, gitlabEmail, userAfterSignIn.Email)
78
78
}
79
79
+1
-1
tests/integration/rename_branch_test.go
+1
-1
tests/integration/rename_branch_test.go
···
165
165
166
166
flashCookie := session.GetCookie(gitea_context.CookieNameFlash)
167
167
assert.NotNil(t, flashCookie)
168
-
assert.EqualValues(t, "error%3DCannot%2Brename%2Bbranch%2Bmain2%2Bbecause%2Bit%2Bis%2Ba%2Bprotected%2Bbranch.", flashCookie.Value)
168
+
assert.Equal(t, "error%3DCannot%2Brename%2Bbranch%2Bmain2%2Bbecause%2Bit%2Bis%2Ba%2Bprotected%2Bbranch.", flashCookie.Value)
169
169
170
170
// Verify it didn't change.
171
171
repo1 := unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{ID: 1})
+1
-1
tests/integration/repo_activity_test.go
+1
-1
tests/integration/repo_activity_test.go
···
35
35
testEditFile(t, session, "user1", "repo1", "master", "README.md", "Hello, World (Edited)\n")
36
36
resp := testPullCreate(t, session, "user1", "repo1", false, "master", "master", "This is a pull title")
37
37
elem := strings.Split(test.RedirectURL(resp), "/")
38
-
assert.EqualValues(t, "pulls", elem[3])
38
+
assert.Equal(t, "pulls", elem[3])
39
39
testPullMerge(t, session, elem[1], elem[2], elem[4], repo_model.MergeStyleMerge, false)
40
40
41
41
testEditFileToNewBranch(t, session, "user1", "repo1", "master", "feat/better_readme", "README.md", "Hello, World (Edited Again)\n")
+3
-3
tests/integration/repo_collaborator_test.go
+3
-3
tests/integration/repo_collaborator_test.go
···
24
24
page := NewHTMLParser(t, response.Body).Find(".repo-setting-content")
25
25
26
26
// Veirfy header
27
-
assert.EqualValues(t, "Collaborators", strings.TrimSpace(page.Find("h4").Text()))
27
+
assert.Equal(t, "Collaborators", strings.TrimSpace(page.Find("h4").Text()))
28
28
29
29
// Veirfy button text
30
30
page = page.Find("#repo-collab-form")
31
-
assert.EqualValues(t, "Add collaborator", strings.TrimSpace(page.Find("button.primary").Text()))
31
+
assert.Equal(t, "Add collaborator", strings.TrimSpace(page.Find("button.primary").Text()))
32
32
33
33
// Veirfy placeholder
34
34
placeholder, exists := page.Find("#search-user-box input").Attr("placeholder")
35
35
assert.True(t, exists)
36
-
assert.EqualValues(t, "Search users…", placeholder)
36
+
assert.Equal(t, "Search users…", placeholder)
37
37
}
+1
-1
tests/integration/repo_commits_search_test.go
+1
-1
tests/integration/repo_commits_search_test.go
···
23
23
24
24
doc := NewHTMLParser(t, resp.Body)
25
25
sel := doc.doc.Find("#commits-table tbody tr td.sha a")
26
-
assert.EqualValues(t, commit, strings.TrimSpace(sel.Text()))
26
+
assert.Equal(t, commit, strings.TrimSpace(sel.Text()))
27
27
}
28
28
29
29
func TestRepoCommitsSearch(t *testing.T) {
+1
-1
tests/integration/repo_commits_test.go
+1
-1
tests/integration/repo_commits_test.go
···
101
101
assert.Equal(t, api.CommitStatusState(state), statuses[0].State)
102
102
assert.Equal(t, setting.AppURL+"api/v1/repos/user2/repo1/statuses/65f1bf27bc3bf70f64657658635e66094edbcb4d", statuses[0].URL)
103
103
assert.Equal(t, "http://test.ci/", statuses[0].TargetURL)
104
-
assert.Equal(t, "", statuses[0].Description)
104
+
assert.Empty(t, statuses[0].Description)
105
105
assert.Equal(t, "testci", statuses[0].Context)
106
106
107
107
assert.Len(t, status.Statuses, 1)
+1
-1
tests/integration/repo_fork_test.go
+1
-1
tests/integration/repo_fork_test.go
···
135
135
htmlDoc := NewHTMLParser(t, resp.Body)
136
136
137
137
forkButton := htmlDoc.Find("a[href*='/forks']")
138
-
assert.EqualValues(t, 1, forkButton.Length())
138
+
assert.Equal(t, 1, forkButton.Length())
139
139
140
140
href, _ := forkButton.Attr("href")
141
141
assert.Equal(t, "/user2/repo1/forks", href)
+2
-2
tests/integration/repo_generate_test.go
+2
-2
tests/integration/repo_generate_test.go
···
36
36
37
37
// Verify form header
38
38
header := strings.TrimSpace(htmlDoc.doc.Find(".form[action='/repo/create'] .header").Text())
39
-
assert.EqualValues(t, locale.TrString("new_repo.title"), header)
39
+
assert.Equal(t, locale.TrString("new_repo.title"), header)
40
40
41
41
htmlDoc.AssertDropdownHasSelectedOption(t, "uid", strconv.FormatInt(owner.ID, 10))
42
42
···
157
157
})
158
158
resp := session.MakeRequest(t, req, http.StatusSeeOther)
159
159
160
-
assert.EqualValues(t, "/user2/spaced-name", test.RedirectURL(resp))
160
+
assert.Equal(t, "/user2/spaced-name", test.RedirectURL(resp))
161
161
unittest.AssertExistsAndLoadBean(t, &repo_model.Repository{OwnerID: 2, Name: "spaced-name"})
162
162
}
163
163
+1
-1
tests/integration/repo_mergecommit_revert_test.go
+1
-1
tests/integration/repo_mergecommit_revert_test.go
···
34
34
resp = session.MakeRequest(t, req, http.StatusSeeOther)
35
35
36
36
// A successful revert redirects to the main branch
37
-
assert.EqualValues(t, "/user2/test_commit_revert/src/branch/main", resp.Header().Get("Location"))
37
+
assert.Equal(t, "/user2/test_commit_revert/src/branch/main", resp.Header().Get("Location"))
38
38
}
+2
-2
tests/integration/repo_migration_ui_test.go
+2
-2
tests/integration/repo_migration_ui_test.go
···
105
105
t.Helper()
106
106
107
107
// Compare lengths of item lists
108
-
assert.EqualValues(t, len(expectedItems), items.Length())
108
+
assert.Equal(t, len(expectedItems), items.Length())
109
109
110
110
// Compare contents of item lists
111
111
for index, expectedName := range expectedItems {
112
112
name, exists := items.Eq(index).Attr("name")
113
113
assert.True(t, exists)
114
-
assert.EqualValues(t, expectedName, name)
114
+
assert.Equal(t, expectedName, name)
115
115
}
116
116
}
+3
-3
tests/integration/repo_search_test.go
+3
-3
tests/integration/repo_search_test.go
···
100
100
container := doc.Find(".repository").Find(".ui.container")
101
101
102
102
branchDropdown := container.Find(".js-branch-tag-selector")
103
-
assert.EqualValues(t, indexer, len(branchDropdown.Nodes) == 0)
103
+
assert.Equal(t, indexer, len(branchDropdown.Nodes) == 0)
104
104
105
105
dropdownOptions := container.
106
106
Find(".menu[data-test-tag=fuzzy-dropdown]").
···
112
112
})
113
113
114
114
if indexer {
115
-
assert.EqualValues(t, []string{"exact", "union"}, dropdownOptions)
115
+
assert.Equal(t, []string{"exact", "union"}, dropdownOptions)
116
116
} else {
117
-
assert.EqualValues(t, []string{"exact", "union", "regexp"}, dropdownOptions)
117
+
assert.Equal(t, []string{"exact", "union", "regexp"}, dropdownOptions)
118
118
}
119
119
120
120
filenames := resultFilenames(t, doc)
+1
-1
tests/integration/repo_settings_test.go
+1
-1
tests/integration/repo_settings_test.go
···
263
263
session.MakeRequest(t, req, http.StatusSeeOther)
264
264
flashCookie := session.GetCookie(gitea_context.CookieNameFlash)
265
265
assert.NotNil(t, flashCookie)
266
-
assert.EqualValues(t, "error%3DThere%2Bis%2Balready%2Ba%2Brule%2Bfor%2Bthis%2Bset%2Bof%2Bbranches", flashCookie.Value)
266
+
assert.Equal(t, "error%3DThere%2Bis%2Balready%2Ba%2Brule%2Bfor%2Bthis%2Bset%2Bof%2Bbranches", flashCookie.Value)
267
267
268
268
// Verify it wasn't added.
269
269
unittest.AssertCount(t, &git_model.ProtectedBranch{RuleName: "master", RepoID: repo.ID}, 1)
+22
-22
tests/integration/repo_test.go
+22
-22
tests/integration/repo_test.go
···
96
96
})
97
97
98
98
commitT := time.Date(2017, time.June, 14, 13, 54, 21, 0, time.UTC).In(time.Local).Format(time.RFC1123)
99
-
assert.EqualValues(t, []file{
99
+
assert.Equal(t, []file{
100
100
{
101
101
fileName: "doc",
102
102
commitID: "2a47ca4b614a9f5a43abbd5ad851a54a616ffee6",
···
218
218
defer tests.PrintCurrentTest(t)()
219
219
220
220
htmlTitle := GetHTMLTitle(t, nil, "/user2/repo1")
221
-
assert.EqualValues(t, "user2/repo1 - Forgejo: Beyond coding. We Forge.", htmlTitle)
221
+
assert.Equal(t, "user2/repo1 - Forgejo: Beyond coding. We Forge.", htmlTitle)
222
222
})
223
223
t.Run("With description", func(t *testing.T) {
224
224
defer tests.PrintCurrentTest(t)()
225
225
226
226
htmlTitle := GetHTMLTitle(t, nil, "/user27/repo49")
227
-
assert.EqualValues(t, "user27/repo49: A wonderful repository with more than just a README.md - Forgejo: Beyond coding. We Forge.", htmlTitle)
227
+
assert.Equal(t, "user27/repo49: A wonderful repository with more than just a README.md - Forgejo: Beyond coding. We Forge.", htmlTitle)
228
228
})
229
229
})
230
230
···
234
234
defer tests.PrintCurrentTest(t)()
235
235
236
236
htmlTitle := GetHTMLTitle(t, nil, "/user2/repo59/src/branch/master/deep/nesting")
237
-
assert.EqualValues(t, "repo59/deep/nesting at master - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
237
+
assert.Equal(t, "repo59/deep/nesting at master - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
238
238
})
239
239
t.Run("Non-default branch", func(t *testing.T) {
240
240
defer tests.PrintCurrentTest(t)()
241
241
242
242
htmlTitle := GetHTMLTitle(t, nil, "/user2/repo59/src/branch/cake-recipe/deep/nesting")
243
-
assert.EqualValues(t, "repo59/deep/nesting at cake-recipe - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
243
+
assert.Equal(t, "repo59/deep/nesting at cake-recipe - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
244
244
})
245
245
t.Run("Commit", func(t *testing.T) {
246
246
defer tests.PrintCurrentTest(t)()
247
247
248
248
htmlTitle := GetHTMLTitle(t, nil, "/user2/repo59/src/commit/d8f53dfb33f6ccf4169c34970b5e747511c18beb/deep/nesting/")
249
-
assert.EqualValues(t, "repo59/deep/nesting at d8f53dfb33f6ccf4169c34970b5e747511c18beb - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
249
+
assert.Equal(t, "repo59/deep/nesting at d8f53dfb33f6ccf4169c34970b5e747511c18beb - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
250
250
})
251
251
t.Run("Tag", func(t *testing.T) {
252
252
defer tests.PrintCurrentTest(t)()
253
253
254
254
htmlTitle := GetHTMLTitle(t, nil, "/user2/repo59/src/tag/v1.0/deep/nesting/")
255
-
assert.EqualValues(t, "repo59/deep/nesting at v1.0 - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
255
+
assert.Equal(t, "repo59/deep/nesting at v1.0 - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
256
256
})
257
257
})
258
258
t.Run("File", func(t *testing.T) {
···
260
260
defer tests.PrintCurrentTest(t)()
261
261
262
262
htmlTitle := GetHTMLTitle(t, nil, "/user2/repo59/src/branch/master/deep/nesting/folder/secret_sauce_recipe.txt")
263
-
assert.EqualValues(t, "repo59/deep/nesting/folder/secret_sauce_recipe.txt at master - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
263
+
assert.Equal(t, "repo59/deep/nesting/folder/secret_sauce_recipe.txt at master - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
264
264
})
265
265
t.Run("Non-default branch", func(t *testing.T) {
266
266
defer tests.PrintCurrentTest(t)()
267
267
268
268
htmlTitle := GetHTMLTitle(t, nil, "/user2/repo59/src/branch/cake-recipe/deep/nesting/folder/secret_sauce_recipe.txt")
269
-
assert.EqualValues(t, "repo59/deep/nesting/folder/secret_sauce_recipe.txt at cake-recipe - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
269
+
assert.Equal(t, "repo59/deep/nesting/folder/secret_sauce_recipe.txt at cake-recipe - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
270
270
})
271
271
t.Run("Commit", func(t *testing.T) {
272
272
defer tests.PrintCurrentTest(t)()
273
273
274
274
htmlTitle := GetHTMLTitle(t, nil, "/user2/repo59/src/commit/d8f53dfb33f6ccf4169c34970b5e747511c18beb/deep/nesting/folder/secret_sauce_recipe.txt")
275
-
assert.EqualValues(t, "repo59/deep/nesting/folder/secret_sauce_recipe.txt at d8f53dfb33f6ccf4169c34970b5e747511c18beb - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
275
+
assert.Equal(t, "repo59/deep/nesting/folder/secret_sauce_recipe.txt at d8f53dfb33f6ccf4169c34970b5e747511c18beb - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
276
276
})
277
277
t.Run("Tag", func(t *testing.T) {
278
278
defer tests.PrintCurrentTest(t)()
279
279
280
280
htmlTitle := GetHTMLTitle(t, nil, "/user2/repo59/src/tag/v1.0/deep/nesting/folder/secret_sauce_recipe.txt")
281
-
assert.EqualValues(t, "repo59/deep/nesting/folder/secret_sauce_recipe.txt at v1.0 - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
281
+
assert.Equal(t, "repo59/deep/nesting/folder/secret_sauce_recipe.txt at v1.0 - user2/repo59 - Forgejo: Beyond coding. We Forge.", htmlTitle)
282
282
})
283
283
})
284
284
})
···
288
288
defer tests.PrintCurrentTest(t)()
289
289
290
290
htmlTitle := GetHTMLTitle(t, nil, "/user2/repo1/issues")
291
-
assert.EqualValues(t, "Issues - user2/repo1 - Forgejo: Beyond coding. We Forge.", htmlTitle)
291
+
assert.Equal(t, "Issues - user2/repo1 - Forgejo: Beyond coding. We Forge.", htmlTitle)
292
292
})
293
293
t.Run("View issue page", func(t *testing.T) {
294
294
defer tests.PrintCurrentTest(t)()
295
295
296
296
htmlTitle := GetHTMLTitle(t, nil, "/user2/repo1/issues/1")
297
-
assert.EqualValues(t, "#1 - issue1 - user2/repo1 - Forgejo: Beyond coding. We Forge.", htmlTitle)
297
+
assert.Equal(t, "#1 - issue1 - user2/repo1 - Forgejo: Beyond coding. We Forge.", htmlTitle)
298
298
})
299
299
})
300
300
···
303
303
defer tests.PrintCurrentTest(t)()
304
304
305
305
htmlTitle := GetHTMLTitle(t, nil, "/user2/repo1/pulls")
306
-
assert.EqualValues(t, "Pull requests - user2/repo1 - Forgejo: Beyond coding. We Forge.", htmlTitle)
306
+
assert.Equal(t, "Pull requests - user2/repo1 - Forgejo: Beyond coding. We Forge.", htmlTitle)
307
307
})
308
308
t.Run("View pull request", func(t *testing.T) {
309
309
defer tests.PrintCurrentTest(t)()
310
310
311
311
htmlTitle := GetHTMLTitle(t, nil, "/user2/repo1/pulls/2")
312
-
assert.EqualValues(t, "#2 - issue2 - user2/repo1 - Forgejo: Beyond coding. We Forge.", htmlTitle)
312
+
assert.Equal(t, "#2 - issue2 - user2/repo1 - Forgejo: Beyond coding. We Forge.", htmlTitle)
313
313
})
314
314
})
315
315
}
···
328
328
repoTopics := htmlDoc.doc.Find("#repo-topics")
329
329
repoSummary := htmlDoc.doc.Find(".repository-summary")
330
330
331
-
assert.EqualValues(t, 0, description.Length())
332
-
assert.EqualValues(t, 0, repoTopics.Length())
333
-
assert.EqualValues(t, 0, repoSummary.Length())
331
+
assert.Equal(t, 0, description.Length())
332
+
assert.Equal(t, 0, repoTopics.Length())
333
+
assert.Equal(t, 0, repoSummary.Length())
334
334
}
335
335
336
336
func TestViewFileInRepoRSSFeed(t *testing.T) {
···
384
384
repoTopics := htmlDoc.doc.Find("#repo-topics")
385
385
repoSummary := htmlDoc.doc.Find(".repository-summary")
386
386
387
-
assert.EqualValues(t, 0, description.Length())
388
-
assert.EqualValues(t, 0, repoTopics.Length())
389
-
assert.EqualValues(t, 0, repoSummary.Length())
387
+
assert.Equal(t, 0, description.Length())
388
+
assert.Equal(t, 0, repoTopics.Length())
389
+
assert.Equal(t, 0, repoSummary.Length())
390
390
})
391
391
392
392
t.Run("File size", func(t *testing.T) {
···
885
885
return s.AttrOr("data-entryname", "")
886
886
})
887
887
888
-
assert.EqualValues(t, []string{"Charlie", "alpha", "Beta", "delta", "licensa", "LICENSE", "licensz", "README.md", "zEta"}, filesList)
888
+
assert.Equal(t, []string{"Charlie", "alpha", "Beta", "delta", "licensa", "LICENSE", "licensz", "README.md", "zEta"}, filesList)
889
889
})
890
890
}
891
891
+3
-3
tests/integration/repo_topic_test.go
+3
-3
tests/integration/repo_topic_test.go
···
32
32
res := MakeRequest(t, NewRequest(t, "GET", searchURL.String()), http.StatusOK)
33
33
DecodeJSON(t, res, &topics)
34
34
assert.Len(t, topics.TopicNames, 4)
35
-
assert.EqualValues(t, "6", res.Header().Get("x-total-count"))
35
+
assert.Equal(t, "6", res.Header().Get("x-total-count"))
36
36
37
37
query.Add("q", "topic")
38
38
searchURL.RawQuery = query.Encode()
···
46
46
DecodeJSON(t, res, &topics)
47
47
if assert.Len(t, topics.TopicNames, 1) {
48
48
assert.EqualValues(t, 2, topics.TopicNames[0].ID)
49
-
assert.EqualValues(t, "database", topics.TopicNames[0].Name)
50
-
assert.EqualValues(t, 1, topics.TopicNames[0].RepoCount)
49
+
assert.Equal(t, "database", topics.TopicNames[0].Name)
50
+
assert.Equal(t, 1, topics.TopicNames[0].RepoCount)
51
51
}
52
52
}
53
53
+1
-1
tests/integration/repo_wiki_test.go
+1
-1
tests/integration/repo_wiki_test.go
+25
-25
tests/integration/repofiles_change_test.go
+25
-25
tests/integration/repofiles_change_test.go
···
265
265
lastCommit, err := gitRepo.GetCommitByPath("new/file.txt")
266
266
require.NoError(t, err)
267
267
expectedFileResponse := getExpectedFileResponseForRepofilesCreate(commitID, lastCommit.ID.String())
268
-
assert.EqualValues(t, expectedFileResponse.Content, filesResponse.Files[0])
269
-
assert.EqualValues(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
270
-
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
271
-
assert.EqualValues(t, expectedFileResponse.Commit.Author.Email, filesResponse.Commit.Author.Email)
272
-
assert.EqualValues(t, expectedFileResponse.Commit.Author.Name, filesResponse.Commit.Author.Name)
268
+
assert.Equal(t, expectedFileResponse.Content, filesResponse.Files[0])
269
+
assert.Equal(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
270
+
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
271
+
assert.Equal(t, expectedFileResponse.Commit.Author.Email, filesResponse.Commit.Author.Email)
272
+
assert.Equal(t, expectedFileResponse.Commit.Author.Name, filesResponse.Commit.Author.Name)
273
273
})
274
274
275
275
t.Run("Update", func(t *testing.T) {
···
283
283
lastCommit, err := commit.GetCommitByPath(opts.Files[0].TreePath)
284
284
require.NoError(t, err)
285
285
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String())
286
-
assert.EqualValues(t, expectedFileResponse.Content, filesResponse.Files[0])
287
-
assert.EqualValues(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
288
-
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
289
-
assert.EqualValues(t, expectedFileResponse.Commit.Author.Email, filesResponse.Commit.Author.Email)
290
-
assert.EqualValues(t, expectedFileResponse.Commit.Author.Name, filesResponse.Commit.Author.Name)
286
+
assert.Equal(t, expectedFileResponse.Content, filesResponse.Files[0])
287
+
assert.Equal(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
288
+
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
289
+
assert.Equal(t, expectedFileResponse.Commit.Author.Email, filesResponse.Commit.Author.Email)
290
+
assert.Equal(t, expectedFileResponse.Commit.Author.Name, filesResponse.Commit.Author.Name)
291
291
})
292
292
293
293
t.Run("Update and move", func(t *testing.T) {
···
318
318
assert.Nil(t, fromEntry) // Should no longer exist here
319
319
assert.NotNil(t, toEntry) // Should exist here
320
320
// assert SHA has remained the same but paths use the new file name
321
-
assert.EqualValues(t, expectedFileResponse.Content.SHA, filesResponse.Files[0].SHA)
322
-
assert.EqualValues(t, expectedFileResponse.Content.Name, filesResponse.Files[0].Name)
323
-
assert.EqualValues(t, expectedFileResponse.Content.Path, filesResponse.Files[0].Path)
324
-
assert.EqualValues(t, expectedFileResponse.Content.URL, filesResponse.Files[0].URL)
325
-
assert.EqualValues(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
326
-
assert.EqualValues(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
321
+
assert.Equal(t, expectedFileResponse.Content.SHA, filesResponse.Files[0].SHA)
322
+
assert.Equal(t, expectedFileResponse.Content.Name, filesResponse.Files[0].Name)
323
+
assert.Equal(t, expectedFileResponse.Content.Path, filesResponse.Files[0].Path)
324
+
assert.Equal(t, expectedFileResponse.Content.URL, filesResponse.Files[0].URL)
325
+
assert.Equal(t, expectedFileResponse.Commit.SHA, filesResponse.Commit.SHA)
326
+
assert.Equal(t, expectedFileResponse.Commit.HTMLURL, filesResponse.Commit.HTMLURL)
327
327
})
328
328
329
329
t.Run("Change without branch names", func(t *testing.T) {
···
340
340
commit, _ := gitRepo.GetBranchCommit(repo.DefaultBranch)
341
341
lastCommit, _ := commit.GetCommitByPath(opts.Files[0].TreePath)
342
342
expectedFileResponse := getExpectedFileResponseForRepofilesUpdate(commit.ID.String(), opts.Files[0].TreePath, lastCommit.ID.String())
343
-
assert.EqualValues(t, expectedFileResponse.Content, filesResponse.Files[0])
343
+
assert.Equal(t, expectedFileResponse.Content, filesResponse.Files[0])
344
344
})
345
345
346
346
t.Run("Delete files", func(t *testing.T) {
···
352
352
expectedFileResponse := getExpectedFileResponseForRepofilesDelete()
353
353
assert.NotNil(t, filesResponse)
354
354
assert.Nil(t, filesResponse.Files[0])
355
-
assert.EqualValues(t, expectedFileResponse.Commit.Message, filesResponse.Commit.Message)
356
-
assert.EqualValues(t, expectedFileResponse.Commit.Author.Identity, filesResponse.Commit.Author.Identity)
357
-
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Identity, filesResponse.Commit.Committer.Identity)
358
-
assert.EqualValues(t, expectedFileResponse.Verification, filesResponse.Verification)
355
+
assert.Equal(t, expectedFileResponse.Commit.Message, filesResponse.Commit.Message)
356
+
assert.Equal(t, expectedFileResponse.Commit.Author.Identity, filesResponse.Commit.Author.Identity)
357
+
assert.Equal(t, expectedFileResponse.Commit.Committer.Identity, filesResponse.Commit.Committer.Identity)
358
+
assert.Equal(t, expectedFileResponse.Verification, filesResponse.Verification)
359
359
360
360
filesResponse, err = files_service.ChangeRepoFiles(git.DefaultContext, repo, doer, opts)
361
361
assert.Nil(t, filesResponse)
···
376
376
expectedFileResponse := getExpectedFileResponseForRepofilesDelete()
377
377
assert.NotNil(t, filesResponse)
378
378
assert.Nil(t, filesResponse.Files[0])
379
-
assert.EqualValues(t, expectedFileResponse.Commit.Message, filesResponse.Commit.Message)
380
-
assert.EqualValues(t, expectedFileResponse.Commit.Author.Identity, filesResponse.Commit.Author.Identity)
381
-
assert.EqualValues(t, expectedFileResponse.Commit.Committer.Identity, filesResponse.Commit.Committer.Identity)
382
-
assert.EqualValues(t, expectedFileResponse.Verification, filesResponse.Verification)
379
+
assert.Equal(t, expectedFileResponse.Commit.Message, filesResponse.Commit.Message)
380
+
assert.Equal(t, expectedFileResponse.Commit.Author.Identity, filesResponse.Commit.Author.Identity)
381
+
assert.Equal(t, expectedFileResponse.Commit.Committer.Identity, filesResponse.Commit.Committer.Identity)
382
+
assert.Equal(t, expectedFileResponse.Verification, filesResponse.Verification)
383
383
})
384
384
})
385
385
}
+2
-2
tests/integration/runner_test.go
+2
-2
tests/integration/runner_test.go
···
61
61
sess.MakeRequest(t, req, http.StatusSeeOther)
62
62
flashCookie := sess.GetCookie(forgejo_context.CookieNameFlash)
63
63
assert.NotNil(t, flashCookie)
64
-
assert.EqualValues(t, "success%3DRunner%2Bupdated%2Bsuccessfully", flashCookie.Value)
64
+
assert.Equal(t, "success%3DRunner%2Bupdated%2Bsuccessfully", flashCookie.Value)
65
65
}
66
66
67
67
req = NewRequestWithValues(t, "POST", baseURL+fmt.Sprintf("/%d/delete", id), map[string]string{
···
73
73
sess.MakeRequest(t, req, http.StatusOK)
74
74
flashCookie := sess.GetCookie(forgejo_context.CookieNameFlash)
75
75
assert.NotNil(t, flashCookie)
76
-
assert.EqualValues(t, "success%3DRunner%2Bdeleted%2Bsuccessfully", flashCookie.Value)
76
+
assert.Equal(t, "success%3DRunner%2Bdeleted%2Bsuccessfully", flashCookie.Value)
77
77
}
78
78
}
79
79
+2
-2
tests/integration/session_test.go
+2
-2
tests/integration/session_test.go
···
28
28
29
29
sess, err := auth.RegenerateSession(db.DefaultContext, "", key)
30
30
require.NoError(t, err)
31
-
assert.EqualValues(t, key, sess.Key)
31
+
assert.Equal(t, key, sess.Key)
32
32
assert.Empty(t, sess.Data, 0)
33
33
34
34
sess, err = auth.ReadSession(db.DefaultContext, key2)
35
35
require.NoError(t, err)
36
-
assert.EqualValues(t, key2, sess.Key)
36
+
assert.Equal(t, key2, sess.Key)
37
37
assert.Empty(t, sess.Data, 0)
38
38
}
+1
-1
tests/integration/signin_test.go
+1
-1
tests/integration/signin_test.go
+1
-1
tests/integration/user_avatar_test.go
+1
-1
tests/integration/user_avatar_test.go
···
81
81
82
82
req = NewRequestf(t, "GET", "/%s.png", user2.Name)
83
83
resp := MakeRequest(t, req, http.StatusSeeOther)
84
-
assert.EqualValues(t, fmt.Sprintf("/avatars/%s", user2.Avatar), resp.Header().Get("location"))
84
+
assert.Equal(t, fmt.Sprintf("/avatars/%s", user2.Avatar), resp.Header().Get("location"))
85
85
86
86
// Can't test if the response matches because the image is re-generated on upload but checking that this at least doesn't give a 404 should be enough.
87
87
}
+6
-6
tests/integration/user_dashboard_test.go
+6
-6
tests/integration/user_dashboard_test.go
···
33
33
response := session.MakeRequest(t, NewRequest(t, "GET", "/"), http.StatusOK)
34
34
page := NewHTMLParser(t, response.Body)
35
35
links := page.Find("#navbar .dropdown[data-tooltip-content='Create…'] .menu")
36
-
assert.EqualValues(t, locale.TrString("new_repo.link"), strings.TrimSpace(links.Find("a[href='/repo/create']").Text()))
37
-
assert.EqualValues(t, locale.TrString("new_migrate.link"), strings.TrimSpace(links.Find("a[href='/repo/migrate']").Text()))
38
-
assert.EqualValues(t, locale.TrString("new_org.link"), strings.TrimSpace(links.Find("a[href='/org/create']").Text()))
36
+
assert.Equal(t, locale.TrString("new_repo.link"), strings.TrimSpace(links.Find("a[href='/repo/create']").Text()))
37
+
assert.Equal(t, locale.TrString("new_migrate.link"), strings.TrimSpace(links.Find("a[href='/repo/migrate']").Text()))
38
+
assert.Equal(t, locale.TrString("new_org.link"), strings.TrimSpace(links.Find("a[href='/org/create']").Text()))
39
39
}
40
40
41
41
func TestUserDashboardFeedWelcome(t *testing.T) {
···
93
93
htmlDoc.doc.Find("#activity-feed .flex-item-main .title").Each(func(i int, s *goquery.Selection) {
94
94
count++
95
95
if s.IsMatcher(goquery.Single("a")) {
96
-
assert.EqualValues(t, "❗ not rendered", s.Text())
96
+
assert.Equal(t, "❗ not rendered", s.Text())
97
97
} else {
98
-
assert.EqualValues(t, ":exclamation: not rendered", s.Text())
98
+
assert.Equal(t, ":exclamation: not rendered", s.Text())
99
99
}
100
100
})
101
101
102
-
assert.EqualValues(t, 6, count)
102
+
assert.Equal(t, 6, count)
103
103
})
104
104
}
+5
-5
tests/integration/user_profile_activity_test.go
+5
-5
tests/integration/user_profile_activity_test.go
···
52
52
53
53
// When profile activity is configured as public, but the profile is private, tell the user about this and link to visibility settings.
54
54
hintLink := testUser2ActivityVisibility(t, userRegular, "Your activity is only visible to you and the instance administrators because your profile is private. Configure.", true)
55
-
assert.EqualValues(t, "/user/settings#visibility-setting", hintLink)
55
+
assert.Equal(t, "/user/settings#visibility-setting", hintLink)
56
56
57
57
// When the profile is private, tell the admin about this.
58
58
testUser2ActivityVisibility(t, userAdmin, "This activity is visible to you because you're an administrator, but the user wants it to remain private.", true)
···
76
76
testUser2ActivityVisibility(t, userGuest, "This user has disabled the public visibility of the activity.", false)
77
77
78
78
// Verify that Configure link is correct
79
-
assert.EqualValues(t, "/user/settings#keep-activity-private", hintLink)
79
+
assert.Equal(t, "/user/settings#keep-activity-private", hintLink)
80
80
}
81
81
82
82
// testChangeUserActivityVisibility allows to easily change visibility of public activity for a user
···
109
109
hintLink, hintLinkExists := page.Find("#visibility-hint a").Attr("href")
110
110
111
111
// Check that the hint aligns with the actual feed availability
112
-
assert.EqualValues(t, availability, page.Find("#activity-feed").Length() > 0)
112
+
assert.Equal(t, availability, page.Find("#activity-feed").Length() > 0)
113
113
114
114
// Check availability of RSS feed button too
115
-
assert.EqualValues(t, availability, page.Find("#profile-avatar-card a[href='/user2.rss']").Length() > 0)
115
+
assert.Equal(t, availability, page.Find("#profile-avatar-card a[href='/user2.rss']").Length() > 0)
116
116
117
117
// Check that the current tab is displayed and is active regardless of it's actual availability
118
118
// For example, on /<user> it wouldn't be available to guest, but it should be still present on /<user>?tab=activity
···
128
128
t.Helper()
129
129
response := session.MakeRequest(t, NewRequest(t, "GET", "/user2"), http.StatusOK)
130
130
page := NewHTMLParser(t, response.Body)
131
-
assert.EqualValues(t, buttons, page.Find("overflow-menu .item[href='/user2?tab=activity']").Length() > 0)
131
+
assert.Equal(t, buttons, page.Find("overflow-menu .item[href='/user2?tab=activity']").Length() > 0)
132
132
}
+4
-4
tests/integration/user_redirect_test.go
+4
-4
tests/integration/user_redirect_test.go
···
38
38
39
39
flashCookie := session.GetCookie(forgejo_context.CookieNameFlash)
40
40
assert.NotNil(t, flashCookie)
41
-
assert.EqualValues(t, "success%3DYour%2Bprofile%2Bhas%2Bbeen%2Bupdated.", flashCookie.Value)
41
+
assert.Equal(t, "success%3DYour%2Bprofile%2Bhas%2Bbeen%2Bupdated.", flashCookie.Value)
42
42
43
43
unittest.AssertExistsIf(t, true, &user_model.Redirect{LowerName: "user2", RedirectUserID: 2})
44
44
})
···
88
88
session.MakeRequest(t, req, http.StatusSeeOther)
89
89
flashCookie := session.GetCookie(forgejo_context.CookieNameFlash)
90
90
assert.NotNil(t, flashCookie)
91
-
assert.EqualValues(t, "success%3DThe%2Buser%2Baccount%2Bhas%2Bbeen%2Bupdated.", flashCookie.Value)
91
+
assert.Equal(t, "success%3DThe%2Buser%2Baccount%2Bhas%2Bbeen%2Bupdated.", flashCookie.Value)
92
92
93
93
unittest.AssertExistsIf(t, true, &user_model.User{LowerName: "user2"})
94
94
unittest.AssertExistsIf(t, false, &user_model.Redirect{LowerName: "user2", RedirectUserID: 2})
···
105
105
106
106
flashCookie := session.GetCookie(forgejo_context.CookieNameFlash)
107
107
assert.NotNil(t, flashCookie)
108
-
assert.EqualValues(t, "success%3DYour%2Bprofile%2Bhas%2Bbeen%2Bupdated.", flashCookie.Value)
108
+
assert.Equal(t, "success%3DYour%2Bprofile%2Bhas%2Bbeen%2Bupdated.", flashCookie.Value)
109
109
110
110
unittest.AssertExistsIf(t, true, &user_model.Redirect{LowerName: "user2-new", RedirectUserID: 2})
111
111
···
117
117
118
118
flashCookie = session.GetCookie(forgejo_context.CookieNameFlash)
119
119
assert.NotNil(t, flashCookie)
120
-
assert.EqualValues(t, "success%3DYour%2Bprofile%2Bhas%2Bbeen%2Bupdated.", flashCookie.Value)
120
+
assert.Equal(t, "success%3DYour%2Bprofile%2Bhas%2Bbeen%2Bupdated.", flashCookie.Value)
121
121
122
122
unittest.AssertExistsIf(t, false, &user_model.Redirect{LowerName: "user2-new", RedirectUserID: 2})
123
123
unittest.AssertExistsIf(t, true, &user_model.Redirect{LowerName: "user2-new-2", RedirectUserID: 2})
+14
-14
tests/integration/user_test.go
+14
-14
tests/integration/user_test.go
···
318
318
user34 := "the_34-user.with.all.allowedChars"
319
319
req := NewRequestf(t, "GET", "/%s.rss", user34)
320
320
resp := MakeRequest(t, req, http.StatusOK)
321
-
if assert.EqualValues(t, "application/rss+xml;charset=utf-8", resp.Header().Get("Content-Type")) {
321
+
if assert.Equal(t, "application/rss+xml;charset=utf-8", resp.Header().Get("Content-Type")) {
322
322
rssDoc := NewHTMLParser(t, resp.Body).Find("channel")
323
323
title, _ := rssDoc.ChildrenFiltered("title").Html()
324
-
assert.EqualValues(t, "Feed of "the_1-user.with.all.allowedChars"", title)
324
+
assert.Equal(t, "Feed of "the_1-user.with.all.allowedChars"", title)
325
325
description, _ := rssDoc.ChildrenFiltered("description").Html()
326
-
assert.EqualValues(t, "<p dir="auto">some <a href="https://commonmark.org/" rel="nofollow">commonmark</a>!</p>\n", description)
326
+
assert.Equal(t, "<p dir="auto">some <a href="https://commonmark.org/" rel="nofollow">commonmark</a>!</p>\n", description)
327
327
}
328
328
})
329
329
t.Run("Non-existent user", func(t *testing.T) {
···
347
347
stopwatch := unittest.AssertExistsAndLoadBean(t, &issues_model.Stopwatch{UserID: owner.ID})
348
348
issue := unittest.AssertExistsAndLoadBean(t, &issues_model.Issue{ID: stopwatch.IssueID})
349
349
if assert.Len(t, apiWatches, 1) {
350
-
assert.EqualValues(t, stopwatch.CreatedUnix.AsTime().Unix(), apiWatches[0].Created.Unix())
351
-
assert.EqualValues(t, issue.Index, apiWatches[0].IssueIndex)
352
-
assert.EqualValues(t, issue.Title, apiWatches[0].IssueTitle)
353
-
assert.EqualValues(t, repo.Name, apiWatches[0].RepoName)
354
-
assert.EqualValues(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
350
+
assert.Equal(t, stopwatch.CreatedUnix.AsTime().Unix(), apiWatches[0].Created.Unix())
351
+
assert.Equal(t, issue.Index, apiWatches[0].IssueIndex)
352
+
assert.Equal(t, issue.Title, apiWatches[0].IssueTitle)
353
+
assert.Equal(t, repo.Name, apiWatches[0].RepoName)
354
+
assert.Equal(t, repo.OwnerName, apiWatches[0].RepoOwnerName)
355
355
assert.Positive(t, apiWatches[0].Seconds)
356
356
}
357
357
}
···
450
450
assert.Equal(t, enabled, hintChecked)
451
451
452
452
link, _ := htmlDoc.Find("form[action='/user/settings/appearance/language'] a").Attr("href")
453
-
assert.EqualValues(t, "https://forgejo.org/docs/next/contributor/localization/", link)
453
+
assert.Equal(t, "https://forgejo.org/docs/next/contributor/localization/", link)
454
454
}
455
455
456
456
t.Run("view", func(t *testing.T) {
···
706
706
htmlDoc := NewHTMLParser(t, resp.Body)
707
707
708
708
userName := strings.TrimSpace(htmlDoc.Find(".profile-avatar-name .username").Text())
709
-
assert.EqualValues(t, "user2", userName)
709
+
assert.Equal(t, "user2", userName)
710
710
})
711
711
}
712
712
···
934
934
sel := htmlDoc.doc.Find("a.name")
935
935
assert.Len(t, repos, len(sel.Nodes))
936
936
for i := 0; i < len(repos); i++ {
937
-
assert.EqualValues(t, repos[i], strings.TrimSpace(sel.Eq(i).Text()))
937
+
assert.Equal(t, repos[i], strings.TrimSpace(sel.Eq(i).Text()))
938
938
}
939
939
}
940
940
}
···
982
982
authToken, err := auth_model.FindAuthToken(db.DefaultContext, lookupKey, auth_model.UserActivation)
983
983
require.NoError(t, err)
984
984
assert.False(t, authToken.IsExpired())
985
-
assert.EqualValues(t, authToken.HashedValidator, auth_model.HashValidator(rawValidator))
985
+
assert.Equal(t, authToken.HashedValidator, auth_model.HashValidator(rawValidator))
986
986
987
987
t.Run("No password", func(t *testing.T) {
988
988
defer tests.PrintCurrentTest(t)()
···
1052
1052
authToken, err := auth_model.FindAuthToken(db.DefaultContext, lookupKey, auth_model.PasswordReset)
1053
1053
require.NoError(t, err)
1054
1054
assert.False(t, authToken.IsExpired())
1055
-
assert.EqualValues(t, authToken.HashedValidator, auth_model.HashValidator(rawValidator))
1055
+
assert.Equal(t, authToken.HashedValidator, auth_model.HashValidator(rawValidator))
1056
1056
1057
1057
req = NewRequestWithValues(t, "POST", "/user/recover_account", map[string]string{
1058
1058
"_csrf": GetCSRF(t, session, "/user/recover_account"),
···
1111
1111
authToken, err := auth_model.FindAuthToken(db.DefaultContext, lookupKey, auth_model.EmailActivation("newemail@example.org"))
1112
1112
require.NoError(t, err)
1113
1113
assert.False(t, authToken.IsExpired())
1114
-
assert.EqualValues(t, authToken.HashedValidator, auth_model.HashValidator(rawValidator))
1114
+
assert.Equal(t, authToken.HashedValidator, auth_model.HashValidator(rawValidator))
1115
1115
1116
1116
req = NewRequestWithValues(t, "POST", "/user/activate_email", map[string]string{
1117
1117
"code": code,
+2
-2
tests/integration/wiki_test.go
+2
-2
tests/integration/wiki_test.go
···
30
30
func assertFileEqual(t *testing.T, p string, content []byte) {
31
31
bs, err := os.ReadFile(p)
32
32
require.NoError(t, err)
33
-
assert.EqualValues(t, content, bs)
33
+
assert.Equal(t, content, bs)
34
34
}
35
35
36
36
func TestRepoCloneWiki(t *testing.T) {
···
67
67
href, _ := firstAnchor.Attr("href")
68
68
pagePath := strings.TrimPrefix(href, "/user2/repo1/wiki/")
69
69
70
-
assert.EqualValues(t, expectedPagePaths[i], pagePath)
70
+
assert.Equal(t, expectedPagePaths[i], pagePath)
71
71
})
72
72
}
+2
-2
tests/integration/xss_test.go
+2
-2
tests/integration/xss_test.go
···
34
34
req = NewRequestf(t, "GET", "/%s", user.Name)
35
35
resp := session.MakeRequest(t, req, http.StatusOK)
36
36
htmlDoc := NewHTMLParser(t, resp.Body)
37
-
assert.EqualValues(t, 0, htmlDoc.doc.Find("script.evil").Length())
38
-
assert.EqualValues(t, fullName,
37
+
assert.Equal(t, 0, htmlDoc.doc.Find("script.evil").Length())
38
+
assert.Equal(t, fullName,
39
39
htmlDoc.doc.Find("div.content").Find(".header.text.center").Text(),
40
40
)
41
41
}