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

Function TestUserSkillRequestAllowsEscapedMaxSizeContent

coderd/userskills_test.go:284–309  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

282}
283
284func TestUserSkillRequestAllowsEscapedMaxSizeContent(t *testing.T) {
285 t.Parallel()
286
287 adminClient := coderdtest.New(t, nil)
288 firstUser := coderdtest.CreateFirstUser(t, adminClient)
289 ownerClient, _ := coderdtest.CreateAnotherUser(t, adminClient, firstUser.OrganizationID)
290 owner := codersdk.NewExperimentalClient(ownerClient)
291 ctx := testutil.Context(t, testutil.WaitMedium)
292
293 prefix := "---\nname: escaped-limit-skill\ndescription: Escaped\n---\n\n"
294 suffix := "\n"
295 bodyLen := skills.MaxPersonalSkillSizeBytes - len(prefix) - len(suffix)
296 require.Positive(t, bodyLen)
297 content := prefix + strings.Repeat(`"`, bodyLen) + suffix
298 require.Len(t, []byte(content), skills.MaxPersonalSkillSizeBytes)
299
300 raw, err := json.Marshal(codersdk.CreateUserSkillRequest{Content: content})
301 require.NoError(t, err)
302 require.Greater(t, len(raw), skills.MaxPersonalSkillSizeBytes+1024)
303
304 created, err := owner.CreateUserSkill(ctx, codersdk.Me, codersdk.CreateUserSkillRequest{
305 Content: content,
306 })
307 require.NoError(t, err)
308 assert.Equal(t, "escaped-limit-skill", created.Name)
309}
310
311func TestUserSkillMissingAndUpdateMismatch(t *testing.T) {
312 t.Parallel()

Callers

nothing calls this directly

Calls 9

CreateUserSkillMethod · 0.95
NewFunction · 0.92
CreateFirstUserFunction · 0.92
CreateAnotherUserFunction · 0.92
NewExperimentalClientFunction · 0.92
ContextFunction · 0.92
LenMethod · 0.45
MarshalMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected