From 6b3528920fbf18c41d6aeb95498af48443282370 Mon Sep 17 00:00:00 2001 From: Gusted Date: Sat, 29 Jul 2023 23:30:25 +0200 Subject: [PATCH] [TESTS] Add some Wiki unit tests - Just to get 100% coverage on services/wiki/wiki_path.go, nothing special. This is just an formality. (cherry picked from commit cf3f046d7acfad68c165d37cac69d90669561427) --- services/wiki/wiki_test.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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")) +}