MCPcopy Index your code
hub / github.com/coder/coder / TestGroupNameValid

Function TestGroupNameValid

codersdk/name_test.go:254–289  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

252}
253
254func TestGroupNameValid(t *testing.T) {
255 t.Parallel()
256
257 random255String, err := cryptorand.String(255)
258 require.NoError(t, err, "failed to generate 255 random string")
259 random256String, err := cryptorand.String(256)
260 require.NoError(t, err, "failed to generate 256 random string")
261
262 testCases := []struct {
263 Name string
264 Valid bool
265 }{
266 {"", false},
267 {"my-group", true},
268 {"create", false},
269 {"new", false},
270 {"Lord Voldemort Team", false},
271 {random255String, true},
272 {random256String, false},
273 }
274 for _, testCase := range testCases {
275 t.Run(testCase.Name, func(t *testing.T) {
276 t.Parallel()
277 err := codersdk.GroupNameValid(testCase.Name)
278 assert.Equal(
279 t,
280 testCase.Valid,
281 err == nil,
282 "Test case %s failed: expected valid=%t but got error: %v",
283 testCase.Name,
284 testCase.Valid,
285 err,
286 )
287 })
288 }
289}

Callers

nothing calls this directly

Calls 4

StringFunction · 0.92
GroupNameValidFunction · 0.92
RunMethod · 0.65
EqualMethod · 0.45

Tested by

no test coverage detected