Skip to content

Commit 02d5f42

Browse files
earl-warrenGusted
andauthored
add some Wiki unit tests (#26260)
- Just to get 100% coverage on services/wiki/wiki_path.go, nothing special. This is just an formality. (cherry picked from commit 6b3528920fbf18c41d6aeb95498af48443282370) Refs: https://codeberg.org/forgejo/forgejo/pulls/1156 Co-authored-by: Gusted <[email protected]>
1 parent 54c28fd commit 02d5f42

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

services/wiki/wiki_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,3 +307,15 @@ func TestPrepareWikiFileName_FirstPage(t *testing.T) {
307307
assert.NoError(t, err)
308308
assert.EqualValues(t, "Home.md", newWikiPath)
309309
}
310+
311+
func TestWebPathConversion(t *testing.T) {
312+
assert.Equal(t, "path/wiki", WebPathToURLPath(WebPath("path/wiki")))
313+
assert.Equal(t, "wiki", WebPathToURLPath(WebPath("wiki")))
314+
assert.Equal(t, "", WebPathToURLPath(WebPath("")))
315+
}
316+
317+
func TestWebPathFromRequest(t *testing.T) {
318+
assert.Equal(t, WebPath("a%2Fb"), WebPathFromRequest("a/b"))
319+
assert.Equal(t, WebPath("a"), WebPathFromRequest("a"))
320+
assert.Equal(t, WebPath("b"), WebPathFromRequest("a/../b"))
321+
}

0 commit comments

Comments
 (0)