mirror of
https://github.com/go-gitea/gitea
synced 2025-07-23 02:38:35 +00:00
just add some unit tests (#16291)
* code.gitea.io/gitea/routers/utils coverage: 100.0% * code.gitea.io/gitea/routers/install 0% -> 5.0% * ConvertUtf8ToUtf8mb4: make sure DBType is mysql
This commit is contained in:
@@ -62,7 +62,41 @@ func TestIsExternalURL(t *testing.T) {
|
||||
"//try.gitea.io/test?param=false"),
|
||||
newTest(false,
|
||||
"/hey/hey/hey#3244"),
|
||||
newTest(true,
|
||||
"://missing protocol scheme"),
|
||||
} {
|
||||
assert.Equal(t, test.Expected, IsExternalURL(test.RawURL))
|
||||
}
|
||||
}
|
||||
|
||||
func TestSanitizeFlashErrorString(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
arg string
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "no error",
|
||||
arg: "",
|
||||
want: "",
|
||||
},
|
||||
{
|
||||
name: "normal error",
|
||||
arg: "can not open file: \"abc.exe\"",
|
||||
want: "can not open file: "abc.exe"",
|
||||
},
|
||||
{
|
||||
name: "line break error",
|
||||
arg: "some error:\n\nawesome!",
|
||||
want: "some error:<br><br>awesome!",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if got := SanitizeFlashErrorString(tt.arg); got != tt.want {
|
||||
t.Errorf("SanitizeFlashErrorString() = '%v', want '%v'", got, tt.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user