(t *testing.T)
| 210 | } |
| 211 | |
| 212 | func TestUserRealNameValid(t *testing.T) { |
| 213 | t.Parallel() |
| 214 | |
| 215 | testCases := []struct { |
| 216 | Name string |
| 217 | Valid bool |
| 218 | }{ |
| 219 | {"", true}, |
| 220 | {" a", false}, |
| 221 | {"a ", false}, |
| 222 | {" a ", false}, |
| 223 | {"1", true}, |
| 224 | {"A", true}, |
| 225 | {"A1", true}, |
| 226 | {".", true}, |
| 227 | {"Mr Bean", true}, |
| 228 | {"Severus Snape", true}, |
| 229 | {"Prof. Albus Percival Wulfric Brian Dumbledore", true}, |
| 230 | {"Pablo Diego José Francisco de Paula Juan Nepomuceno María de los Remedios Cipriano de la Santísima Trinidad Ruiz y Picasso", true}, |
| 231 | {"Hector Ó hEochagáin", true}, |
| 232 | {"Małgorzata Kalinowska-Iszkowska", true}, |
| 233 | {"成龍", true}, |
| 234 | {". .", true}, |
| 235 | {"Lord Voldemort ", false}, |
| 236 | {" Bellatrix Lestrange", false}, |
| 237 | {" ", false}, |
| 238 | {strings.Repeat("a", 128), true}, |
| 239 | {strings.Repeat("a", 129), false}, |
| 240 | } |
| 241 | for _, testCase := range testCases { |
| 242 | t.Run(testCase.Name, func(t *testing.T) { |
| 243 | t.Parallel() |
| 244 | err := codersdk.UserRealNameValid(testCase.Name) |
| 245 | norm := codersdk.NormalizeRealUsername(testCase.Name) |
| 246 | normErr := codersdk.UserRealNameValid(norm) |
| 247 | assert.NoError(t, normErr) |
| 248 | assert.Equal(t, testCase.Valid, err == nil) |
| 249 | assert.Equal(t, testCase.Valid, norm == testCase.Name, "invalid name should be different after normalization") |
| 250 | }) |
| 251 | } |
| 252 | } |
| 253 | |
| 254 | func TestGroupNameValid(t *testing.T) { |
| 255 | t.Parallel() |
nothing calls this directly
no test coverage detected