Disallow empty titles (#5785)

* add util method and tests

* make sure the title of an issue cannot be empty

* wiki title cannot be empty

* pull request title cannot be empty

* update to make use of the new util methof
This commit is contained in:
Lanre Adelowo 2019-01-21 12:45:32 +01:00 committed by Lauris BH
parent 8a92544a3e
commit e1fcd6b742
7 changed files with 48 additions and 3 deletions

View file

@ -98,3 +98,8 @@ func Min(a, b int) int {
}
return a
}
// IsEmptyString checks if the provided string is empty
func IsEmptyString(s string) bool {
return len(strings.TrimSpace(s)) == 0
}

View file

@ -77,3 +77,20 @@ func TestIsExternalURL(t *testing.T) {
assert.Equal(t, test.Expected, IsExternalURL(test.RawURL))
}
}
func TestIsEmptyString(t *testing.T) {
cases := []struct {
s string
expected bool
}{
{"", true},
{" ", true},
{" ", true},
{" a", false},
}
for _, v := range cases {
assert.Equal(t, v.expected, IsEmptyString(v.s))
}
}