mirror of
https://github.com/go-gitea/gitea.git
synced 2024-05-11 05:55:29 +00:00
refactor webhook *NewPost (#20729)
* refactor webhook *NewPost * remove empty values * always show errs.Message * remove utils.IsValidSlackChannel * move IsValidSlackChannel to services/webhook package * binding: handle empty Message case * make IsValidSlackChannel more strict
This commit is contained in:
@ -170,3 +170,22 @@ func TestSlackJSONPayload(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
assert.NotEmpty(t, json)
|
||||
}
|
||||
|
||||
func TestIsValidSlackChannel(t *testing.T) {
|
||||
tt := []struct {
|
||||
channelName string
|
||||
expected bool
|
||||
}{
|
||||
{"gitea", true},
|
||||
{"#gitea", true},
|
||||
{" ", false},
|
||||
{"#", false},
|
||||
{" #", false},
|
||||
{"gitea ", false},
|
||||
{" gitea", false},
|
||||
}
|
||||
|
||||
for _, v := range tt {
|
||||
assert.Equal(t, v.expected, IsValidSlackChannel(v.channelName))
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user