From db582d97ef6cd7d9f73a63c99639f6d00f40dc5a Mon Sep 17 00:00:00 2001 From: wxiaoguang Date: Sat, 6 May 2023 19:24:18 +0800 Subject: [PATCH] Improve wiki user title test (#24559) The `..` should be covered by TestUserTitleToWebPath. Otherwise, if the random string is "..", it causes unnecessary failure in TestUserWebGitPathConsistency --- services/wiki/wiki_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/services/wiki/wiki_test.go b/services/wiki/wiki_test.go index a781ebeda..ccb230e06 100644 --- a/services/wiki/wiki_test.go +++ b/services/wiki/wiki_test.go @@ -34,6 +34,9 @@ func TestUserTitleToWebPath(t *testing.T) { UserTitle string } for _, test := range []test{ + {"unnamed", ""}, + {"unnamed", "."}, + {"unnamed", ".."}, {"wiki-name", "wiki name"}, {"title.md.-", "title.md"}, {"wiki-name.-", "wiki-name"}, @@ -118,7 +121,7 @@ func TestUserWebGitPathConsistency(t *testing.T) { } userTitle := strings.TrimSpace(string(b[:l])) - if userTitle == "" || userTitle == "." { + if userTitle == "" || userTitle == "." || userTitle == ".." { continue } webPath := UserTitleToWebPath("", userTitle)