1
0
Fork 0
mirror of https://codeberg.org/forgejo/forgejo.git synced 2024-12-25 02:33:11 +00:00

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 6b3528920f)

Refs: https://codeberg.org/forgejo/forgejo/pulls/1156

Co-authored-by: Gusted <postmaster@gusted.xyz>
This commit is contained in:
Earl Warren 2023-08-03 03:37:48 +02:00 committed by GitHub
parent 54c28fddd8
commit 02d5f422ea
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -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"))
}