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

Function TestUserSkillLimit

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

Source from the content-addressed store, hash-verified

206}
207
208func TestUserSkillLimit(t *testing.T) {
209 t.Parallel()
210
211 adminClient := coderdtest.New(t, nil)
212 firstUser := coderdtest.CreateFirstUser(t, adminClient)
213 ownerClient, _ := coderdtest.CreateAnotherUser(t, adminClient, firstUser.OrganizationID)
214 owner := codersdk.NewExperimentalClient(ownerClient)
215 ctx := testutil.Context(t, testutil.WaitLong)
216
217 for i := range skills.MaxPersonalSkillsPerUser {
218 name := fmt.Sprintf("limit-skill-%03d", i)
219 _, err := owner.CreateUserSkill(ctx, codersdk.Me, codersdk.CreateUserSkillRequest{
220 Content: userSkillMarkdown(name, "Limit", "Body."),
221 })
222 require.NoError(t, err)
223 }
224
225 _, err := owner.CreateUserSkill(ctx, codersdk.Me, codersdk.CreateUserSkillRequest{
226 Content: userSkillMarkdown("limit-skill-overflow", "Limit", "Body."),
227 })
228 sdkErr := requireSDKErrorStatus(t, err, http.StatusConflict)
229 assert.Equal(t, "Personal skill limit reached.", sdkErr.Message)
230 assert.Equal(t,
231 fmt.Sprintf("Each user can have at most %d personal skills.", skills.MaxPersonalSkillsPerUser),
232 sdkErr.Detail,
233 )
234}
235
236func TestUserSkillLimitConcurrentCreates(t *testing.T) {
237 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
requireSDKErrorStatusFunction · 0.85
userSkillMarkdownFunction · 0.70
EqualMethod · 0.45

Tested by

no test coverage detected