(t *testing.T)
| 513 | } |
| 514 | |
| 515 | func TestUserSkillSchemaConstants(t *testing.T) { |
| 516 | t.Parallel() |
| 517 | |
| 518 | _, _, sqlDB := dbtestutil.NewDBWithSQLDB(t) |
| 519 | |
| 520 | ctx := testutil.Context(t, testutil.WaitMedium) |
| 521 | var triggerDef string |
| 522 | require.NoError(t, sqlDB.QueryRowContext( |
| 523 | ctx, |
| 524 | `SELECT pg_get_functiondef('enforce_user_skills_per_user_limit'::regproc)`, |
| 525 | ).Scan(&triggerDef)) |
| 526 | assert.Contains(t, triggerDef, fmt.Sprintf("skill_limit constant int := %d;", skills.MaxPersonalSkillsPerUser)) |
| 527 | |
| 528 | constraints := map[database.CheckConstraint]string{ |
| 529 | database.CheckUserSkillsNameSize: fmt.Sprintf("octet_length(name) <= %d", skills.MaxPersonalSkillNameBytes), |
| 530 | database.CheckUserSkillsNameFormat: "name ~ '^[a-z0-9]+(-[a-z0-9]+)*$'::text", |
| 531 | database.CheckUserSkillsContentSize: fmt.Sprintf("octet_length(content) <= %d", skills.MaxPersonalSkillSizeBytes), |
| 532 | } |
| 533 | for constraint, expected := range constraints { |
| 534 | t.Run(string(constraint), func(t *testing.T) { |
| 535 | t.Parallel() |
| 536 | |
| 537 | ctx := testutil.Context(t, testutil.WaitMedium) |
| 538 | var constraintDef string |
| 539 | require.NoError(t, sqlDB.QueryRowContext( |
| 540 | ctx, |
| 541 | `SELECT pg_get_constraintdef(oid) FROM pg_constraint WHERE conname = $1`, |
| 542 | constraint, |
| 543 | ).Scan(&constraintDef)) |
| 544 | assert.Contains(t, constraintDef, expected) |
| 545 | }) |
| 546 | } |
| 547 | } |
| 548 | |
| 549 | //nolint:paralleltest,tparallel // Subtests share one auditor and run sequentially. |
| 550 | func TestUserSkillAudit(t *testing.T) { |
nothing calls this directly
no test coverage detected