summaryrefslogtreecommitdiffstats
path: root/services/wiki
diff options
context:
space:
mode:
authorEarl Warren <109468362+earl-warren@users.noreply.github.com>2023-08-03 03:37:48 +0200
committerGitHub <noreply@github.com>2023-08-03 03:37:48 +0200
commit02d5f422eab2f2b7ba8f61dcdef5bea96950061a (patch)
tree004a4e75d44040982b9f5444e59dc325d9ab819c /services/wiki
parentClarify the logger's MODE config option (#26267) (diff)
downloadforgejo-02d5f422eab2f2b7ba8f61dcdef5bea96950061a.tar.xz
forgejo-02d5f422eab2f2b7ba8f61dcdef5bea96950061a.zip
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 <postmaster@gusted.xyz>
Diffstat (limited to 'services/wiki')
-rw-r--r--services/wiki/wiki_test.go12
1 files changed, 12 insertions, 0 deletions
diff --git a/services/wiki/wiki_test.go b/services/wiki/wiki_test.go
index ccb230e06f..f126224244 100644
--- a/services/wiki/wiki_test.go
+++ b/services/wiki/wiki_test.go
@@ -307,3 +307,15 @@ func TestPrepareWikiFileName_FirstPage(t *testing.T) {
assert.NoError(t, err)
assert.EqualValues(t, "Home.md", newWikiPath)
}
+
+func TestWebPathConversion(t *testing.T) {
+ assert.Equal(t, "path/wiki", WebPathToURLPath(WebPath("path/wiki")))
+ assert.Equal(t, "wiki", WebPathToURLPath(WebPath("wiki")))
+ assert.Equal(t, "", WebPathToURLPath(WebPath("")))
+}
+
+func TestWebPathFromRequest(t *testing.T) {
+ assert.Equal(t, WebPath("a%2Fb"), WebPathFromRequest("a/b"))
+ assert.Equal(t, WebPath("a"), WebPathFromRequest("a"))
+ assert.Equal(t, WebPath("b"), WebPathFromRequest("a/../b"))
+}