@@ -19,18 +19,14 @@ import (
19
19
"github.com/stretchr/testify/assert"
20
20
)
21
21
22
- const (
23
- AppURL = "http://localhost:3000/"
24
- Repo = "gogits/gogs"
25
- Branch = "main"
26
- FullURL = AppURL + Repo + "/"
27
- )
22
+ const AppURL = "http://localhost:3000/"
28
23
29
- func testRenderMarkup (t * testing.T , mode string , wiki bool , filePath , text , responseBody string , responseCode int ) {
24
+ func testRenderMarkup (t * testing.T , mode string , wiki bool , filePath , text , expectedBody string , expectedCode int ) {
25
+ t .Helper ()
30
26
setting .AppURL = AppURL
31
- context := Repo
27
+ context := "/gogits/gogs"
32
28
if ! wiki {
33
- context += "/src/branch/" + Branch
29
+ context += "/src/branch/main"
34
30
}
35
31
options := api.MarkupOption {
36
32
Mode : mode ,
@@ -42,16 +38,17 @@ func testRenderMarkup(t *testing.T, mode string, wiki bool, filePath, text, resp
42
38
ctx , resp := contexttest .MockAPIContext (t , "POST /api/v1/markup" )
43
39
web .SetForm (ctx , & options )
44
40
Markup (ctx )
45
- assert .Equal (t , responseBody , resp .Body .String ())
46
- assert .Equal (t , responseCode , resp .Code )
41
+ assert .Equal (t , expectedBody , resp .Body .String ())
42
+ assert .Equal (t , expectedCode , resp .Code )
47
43
resp .Body .Reset ()
48
44
}
49
45
50
46
func testRenderMarkdown (t * testing.T , mode string , wiki bool , text , responseBody string , responseCode int ) {
47
+ t .Helper ()
51
48
setting .AppURL = AppURL
52
- context := Repo
49
+ context := "/gogits/gogs"
53
50
if ! wiki {
54
- context += "/src/branch/" + Branch
51
+ context += "/src/branch/main"
55
52
}
56
53
options := api.MarkdownOption {
57
54
Mode : mode ,
@@ -83,20 +80,20 @@ func TestAPI_RenderGFM(t *testing.T) {
83
80
// rendered
84
81
`<p>Wiki! Enjoy :)</p>
85
82
<ul>
86
- <li><a href="` + FullURL + ` wiki/Links" rel="nofollow">Links, Language bindings, Engine bindings</a></li>
87
- <li><a href="` + FullURL + ` wiki/Tips" rel="nofollow">Tips</a></li>
88
- <li>Bezier widget (by <a href="` + AppURL + ` r-lyeh" rel="nofollow">@r-lyeh</a>) <a href="https://github.com/ocornut/imgui/issues/786" rel="nofollow">https://github.com/ocornut/imgui/issues/786</a></li>
83
+ <li><a href="http://localhost:3000/gogits/gogs/ wiki/Links" rel="nofollow">Links, Language bindings, Engine bindings</a></li>
84
+ <li><a href="http://localhost:3000/gogits/gogs/ wiki/Tips" rel="nofollow">Tips</a></li>
85
+ <li>Bezier widget (by <a href="http://localhost:3000/ r-lyeh" rel="nofollow">@r-lyeh</a>) <a href="https://github.com/ocornut/imgui/issues/786" rel="nofollow">https://github.com/ocornut/imgui/issues/786</a></li>
89
86
</ul>
90
87
` ,
91
88
// Guard wiki sidebar: special syntax
92
89
`[[Guardfile-DSL / Configuring-Guard|Guardfile-DSL---Configuring-Guard]]` ,
93
90
// rendered
94
- `<p><a href="` + FullURL + ` wiki/Guardfile-DSL---Configuring-Guard" rel="nofollow">Guardfile-DSL / Configuring-Guard</a></p>
91
+ `<p><a href="http://localhost:3000/gogits/gogs/ wiki/Guardfile-DSL---Configuring-Guard" rel="nofollow">Guardfile-DSL / Configuring-Guard</a></p>
95
92
` ,
96
93
// special syntax
97
94
`[[Name|Link]]` ,
98
95
// rendered
99
- `<p><a href="` + FullURL + ` wiki/Link" rel="nofollow">Name</a></p>
96
+ `<p><a href="http://localhost:3000/gogits/gogs/ wiki/Link" rel="nofollow">Name</a></p>
100
97
` ,
101
98
// empty
102
99
`` ,
@@ -120,8 +117,8 @@ Here are some links to the most important topics. You can find the full list of
120
117
<p><strong>Wine Staging</strong> on website <a href="http://wine-staging.com" rel="nofollow">wine-staging.com</a>.</p>
121
118
<h2 id="user-content-quick-links">Quick Links</h2>
122
119
<p>Here are some links to the most important topics. You can find the full list of pages at the sidebar.</p>
123
- <p><a href="` + FullURL + ` wiki/Configuration" rel="nofollow">Configuration</a>
124
- <a href="` + FullURL + ` wiki/raw/images/icon-bug.png" rel="nofollow"><img src="` + FullURL + ` wiki/raw/images/icon-bug.png" title="icon-bug.png" alt="images/icon-bug.png"/></a></p>
120
+ <p><a href="http://localhost:3000/gogits/gogs/ wiki/Configuration" rel="nofollow">Configuration</a>
121
+ <a href="http://localhost:3000/gogits/gogs/ wiki/raw/images/icon-bug.png" rel="nofollow"><img src="http://localhost:3000/gogits/gogs/ wiki/raw/images/icon-bug.png" title="icon-bug.png" alt="images/icon-bug.png"/></a></p>
125
122
` ,
126
123
}
127
124
@@ -132,8 +129,8 @@ Here are some links to the most important topics. You can find the full list of
132
129
` ,
133
130
// rendered
134
131
`<h1 id="user-content-title">Title</h1>
135
- <p><a href="` + FullURL + ` src/branch/` + Branch + ` /test.md" rel="nofollow">Link</a>
136
- <a href="` + FullURL + ` media/branch/` + Branch + ` /image.png" target="_blank" rel="nofollow noopener"><img src="` + FullURL + ` media/branch/` + Branch + ` /image.png" alt="Image"/></a></p>
132
+ <p><a href="http://localhost:3000/gogits/gogs/ src/branch/main /test.md" rel="nofollow">Link</a>
133
+ <a href="http://localhost:3000/gogits/gogs/ media/branch/main /image.png" target="_blank" rel="nofollow noopener"><img src="http://localhost:3000/gogits/gogs/ media/branch/main /image.png" alt="Image"/></a></p>
137
134
` ,
138
135
}
139
136
@@ -189,7 +186,7 @@ func TestAPI_RenderSimple(t *testing.T) {
189
186
options := api.MarkdownOption {
190
187
Mode : "markdown" ,
191
188
Text : "" ,
192
- Context : Repo ,
189
+ Context : "/gogits/gogs" ,
193
190
}
194
191
ctx , resp := contexttest .MockAPIContext (t , "POST /api/v1/markdown" )
195
192
for i := 0 ; i < len (simpleCases ); i += 2 {
0 commit comments