aboutsummaryrefslogtreecommitdiffstats
path: root/routers/utils/utils_test.go
diff options
context:
space:
mode:
authorLanre Adelowo <adelowomailbox@gmail.com>2018-09-10 15:31:08 +0100
committertechknowlogick <techknowlogick@users.noreply.github.com>2018-09-10 10:31:08 -0400
commitbe48397945c77748d412baad3493bb5bd1c95e2a (patch)
treed53dc2e78052588b6985400b762e994227183e76 /routers/utils/utils_test.go
parent6e03390aa8fa096206457962db1955d642860b57 (diff)
downloadgitea-be48397945c77748d412baad3493bb5bd1c95e2a.tar.gz
gitea-be48397945c77748d412baad3493bb5bd1c95e2a.zip
Slack webhook channel name cannot be empty or just contain an hashtag (#4786)
Diffstat (limited to 'routers/utils/utils_test.go')
-rw-r--r--routers/utils/utils_test.go17
1 files changed, 17 insertions, 0 deletions
diff --git a/routers/utils/utils_test.go b/routers/utils/utils_test.go
index fb56ac85c2..d96e1d7d26 100644
--- a/routers/utils/utils_test.go
+++ b/routers/utils/utils_test.go
@@ -15,3 +15,20 @@ func TestRemoveUsernameParameterSuffix(t *testing.T) {
assert.Equal(t, "foobar", RemoveUsernameParameterSuffix("foobar"))
assert.Equal(t, "", RemoveUsernameParameterSuffix(""))
}
+
+func TestIsValidSlackChannel(t *testing.T) {
+ tt := []struct {
+ channelName string
+ expected bool
+ }{
+ {"gitea", true},
+ {" ", false},
+ {"#", false},
+ {"gitea ", true},
+ {" gitea", true},
+ }
+
+ for _, v := range tt {
+ assert.Equal(t, v.expected, IsValidSlackChannel(v.channelName))
+ }
+}