MM-41909: Allow 1 char channel name (#19845)

* [ MM-41909 ] Allow 1 character channel names

Change minimal length to 1

* [ MM-41909 ] Fix localization string

* [ MM-41909 ] Modify condition to allow 1 char channel name

* [ MM-41909 ] fix formatting

* [MM-41909] Linting fix

* [MM-41909] Fix regex

* [MM-41909] Localization update

* [MM-41909] Attempt to fix test

Co-authored-by: Kevin Jiang <>
Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
Kevin Sicong Jiang
2022-04-13 03:17:15 +12:00
коммит произвёл GitHub
родитель 053e92a683
Коммит 5cb31a114a
6 изменённых файлов: 57 добавлений и 16 удалений

Просмотреть файл

@@ -862,6 +862,55 @@ func TestSanitizeUnicode(t *testing.T) {
}
}
func TestIsValidChannelIdentifier(t *testing.T) {
cases := []struct {
Description string
Input string
Expected bool
}{
{
Description: "less than min length",
Input: "",
Expected: false,
},
{
Description: "single alphabetical char",
Input: "a",
Expected: true,
},
{
Description: "single underscore",
Input: "_",
Expected: false,
},
{
Description: "single hyphen",
Input: "-",
Expected: false,
},
{
Description: "empty string",
Input: " ",
Expected: false,
},
{
Description: "multiple with hyphen",
Input: "a-a",
Expected: true,
},
{
Description: "multiple with hyphen",
Input: "a_a",
Expected: true,
},
}
for _, tc := range cases {
actual := IsValidChannelIdentifier(tc.Input)
require.Equalf(t, actual, tc.Expected, "case: '%v'\tshould returned: %#v", tc.Input, tc.Expected)
}
}
func TestIsValidHTTPURL(t *testing.T) {
t.Parallel()