Skip to content

chore: Cleanup seeder functions to return full structs instead of IDs#4110

Merged
Flo4604 merged 3 commits intomainfrom
ENG-1921-cleanup-seeder-functions
Oct 22, 2025
Merged

chore: Cleanup seeder functions to return full structs instead of IDs#4110
Flo4604 merged 3 commits intomainfrom
ENG-1921-cleanup-seeder-functions

Conversation

@mcstepp
Copy link
Collaborator

@mcstepp mcstepp commented Oct 17, 2025

What does this PR do?

This PR refactors the test seeder functions to return full database structs instead of just IDs, improving type safety and reducing the need for additional database queries in tests.

Changes:

  • Updated seeder functions (CreateRatelimit, CreateIdentity, CreateRole, CreatePermission) to return complete db.* structs instead of string IDs
  • Refactored test files to use the returned structs and access the .ID field when only the ID is needed
  • This makes tests more self-contained and provides direct access to seeded data without additional lookups

Motivation:

Previously, tests that needed information beyond just the ID of a seeded entity had to make additional database queries. By returning the full structs, tests can access all fields directly, making them cleaner and more efficient.

Fixes #3545

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • Enhancement (small improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

Test Steps:

  1. Run the Go test suite to verify all tests pass with the refactored seeder functions:
cd go
make test-unit
  1. Verify specific test files that were updated:
cd go/apps/api
go test ./routes/v2_keys_add_permissions/...
go test ./routes/v2_keys_add_roles/...
go test ./routes/v2_keys_verify_key/...
go test ./routes/v2_keys_whoami/...
go test ./routes/v2_identities_get_identity/...
  1. Confirm that seeder functions return the expected struct types and tests can access both IDs and other fields

Expected Behavior:

  • All existing tests should pass without modification to test logic
  • Tests now have direct access to seeded entity data (e.g., role.ID, permission.Name) without additional database queries
  • No change in test coverage or behavior, only improved code clarity and type safety

Note: There is a pre-existing race condition in the upstream libopenapi-validator library (unrelated to these changes) that may appear when running tests with -race flag. This is a known issue in the validator library itself.

Checklist

Required

  • Filled out the "How to test" section in this PR
  • Read Contributing Guide
  • Self-reviewed my own code
  • Commented on my code in hard-to-understand areas
  • Ran pnpm build
  • Ran pnpm fmt
  • Checked for warnings, there are none
  • Removed all console.logs
  • Merged the latest changes from main onto my branch with git pull origin main
  • My changes don't cause any responsiveness issues

Appreciated

  • If a UI change was made: Added a screen recording or screenshots to this PR
  • Updated the Unkey Docs if changes were necessary

@linear
Copy link

linear bot commented Oct 17, 2025

@changeset-bot
Copy link

changeset-bot bot commented Oct 17, 2025

⚠️ No Changeset found

Latest commit: 68d1977

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@vercel
Copy link

vercel bot commented Oct 17, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
engineering Ready Ready Preview Comment Oct 22, 2025 5:19pm
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
dashboard Ignored Ignored Preview Oct 22, 2025 5:19pm

@github-actions
Copy link
Contributor

github-actions bot commented Oct 17, 2025

Thank you for following the naming conventions for pull request titles! 🙏

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Oct 17, 2025

📝 Walkthrough

Walkthrough

Test helpers and seed utilities now return full db entity structs; tests were updated to capture those structs and use their .ID fields (or .Name where appropriate) when constructing requests and assertions. No API handler logic changed.

Changes

Cohort / File(s) Summary
Route tests (identity/key/permission/role)
go/apps/api/routes/v2_identities_get_identity/200_test.go, go/apps/api/routes/v2_keys_add_permissions/200_test.go, go/apps/api/routes/v2_keys_add_roles/200_test.go, go/apps/api/routes/v2_keys_get_key/200_test.go, go/apps/api/routes/v2_keys_remove_permissions/200_test.go, go/apps/api/routes/v2_keys_remove_permissions/404_test.go, go/apps/api/routes/v2_keys_reroll_key/200_test.go, go/apps/api/routes/v2_keys_verify_key/200_test.go, go/apps/api/routes/v2_keys_verify_key/412_test.go, go/apps/api/routes/v2_keys_verify_key/multilimit_test.go, go/apps/api/routes/v2_keys_whoami/200_test.go
Tests updated to use returned entity objects from helpers and reference their fields (e.g., identity.ID, permission.ID, permission.Name, admin.ID) when building requests and assertions; local variable renames where applicable.
Test harness public methods
go/pkg/testutil/http.go
Changed Harness methods to return concrete db structs instead of string IDs: CreateIdentity, CreateRatelimit, CreateRole, CreatePermission now return db.Identity, db.Ratelimit, db.Role, db.Permission. Implementations delegate to seeder and propagate structs.
Seeder helpers
go/pkg/testutil/seed/seed.go
Seeder creation helpers now return full db.* structs (Identity, Role, Permission, Ratelimit) instead of plain IDs; creation flows updated to populate/return struct fields (IDs, timestamps), propagate IDs into related inserts, and reuse a centralized createdAt.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Test as Test
    participant Harness as TestHarness
    participant Seeder as Seeder
    participant DB as Database

    Note over Test,Harness: Test requests seeded entity
    Test->>Harness: CreatePermission(req)
    Harness->>Seeder: CreatePermission(ctx, req)
    Seeder->>DB: INSERT permission (returns row)
    DB-->>Seeder: db row
    Seeder-->>Harness: db.Permission (full struct)
    Harness-->>Test: db.Permission (full struct)
    Note over Test: Test uses permission.ID / permission.Name in subsequent requests/assertions
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

wakes you up

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (4 passed)
Check name Status Explanation
Title Check ✅ Passed The PR title "chore: Cleanup seeder functions to return full structs instead of IDs" clearly and concisely describes the primary change in the changeset. It directly reflects the main objective of the PR, which is to refactor test seeder utility functions to return complete database structs rather than just ID strings. The title is specific enough that reviewers scanning the commit history would understand the nature of the refactoring without needing to examine the details.
Linked Issues Check ✅ Passed The PR directly addresses all coding requirements from issue #3545. The seeder functions (CreateIdentity, CreateRatelimit, CreateRole, CreatePermission) have been updated to return full db.* structs instead of string IDs, as requested. All test files have been refactored to consume these structs and access the .ID field when needed, eliminating the intermediate variable pattern that was the core concern. The changes enable tests to access all seeded entity fields directly without additional database queries, fulfilling the stated objectives.
Out of Scope Changes Check ✅ Passed All changes in the PR are directly aligned with the objectives of issue #3545. The modifications consist entirely of refactoring seeder utility functions and updating test files to use the new return types. There are no unrelated bug fixes, feature additions, or refactoring efforts outside the scope of this seeder cleanup initiative. The changes are focused and coherent with the stated purpose of returning full structs instead of IDs.
Description Check ✅ Passed The PR description is well-structured and covers all major sections required by the template. It includes a clear summary of changes, references the fixed issue (#3545), specifies the change type as "Chore," provides comprehensive test steps with specific commands, and completes most required checklist items. The author goes beyond the basic template by providing motivation context and additional details about expected behavior. While some non-critical template sections (UI screenshots, documentation updates) are not applicable to this code refactoring, the description demonstrates thorough coverage of the essential requirements.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch ENG-1921-cleanup-seeder-functions

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ce6eb52 and c0ef69f.

📒 Files selected for processing (13)
  • go/apps/api/routes/v2_identities_get_identity/200_test.go (1 hunks)
  • go/apps/api/routes/v2_keys_add_permissions/200_test.go (9 hunks)
  • go/apps/api/routes/v2_keys_add_roles/200_test.go (2 hunks)
  • go/apps/api/routes/v2_keys_get_key/200_test.go (2 hunks)
  • go/apps/api/routes/v2_keys_remove_permissions/200_test.go (7 hunks)
  • go/apps/api/routes/v2_keys_remove_permissions/404_test.go (2 hunks)
  • go/apps/api/routes/v2_keys_reroll_key/200_test.go (2 hunks)
  • go/apps/api/routes/v2_keys_verify_key/200_test.go (3 hunks)
  • go/apps/api/routes/v2_keys_verify_key/412_test.go (2 hunks)
  • go/apps/api/routes/v2_keys_verify_key/multilimit_test.go (5 hunks)
  • go/apps/api/routes/v2_keys_whoami/200_test.go (2 hunks)
  • go/pkg/testutil/http.go (1 hunks)
  • go/pkg/testutil/seed/seed.go (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • go/apps/api/routes/v2_keys_whoami/200_test.go
  • go/apps/api/routes/v2_keys_get_key/200_test.go
  • go/apps/api/routes/v2_keys_verify_key/multilimit_test.go
  • go/apps/api/routes/v2_identities_get_identity/200_test.go
  • go/apps/api/routes/v2_keys_remove_permissions/200_test.go
  • go/apps/api/routes/v2_keys_verify_key/412_test.go
  • go/apps/api/routes/v2_keys_remove_permissions/404_test.go
🧰 Additional context used
🧬 Code graph analysis (6)
go/apps/api/routes/v2_keys_reroll_key/200_test.go (1)
go/pkg/testutil/seed/seed.go (1)
  • CreateIdentityRequest (364-369)
go/apps/api/routes/v2_keys_add_permissions/200_test.go (1)
go/pkg/testutil/seed/seed.go (1)
  • CreatePermissionRequest (453-458)
go/pkg/testutil/http.go (2)
go/pkg/testutil/seed/seed.go (4)
  • CreateIdentityRequest (364-369)
  • CreateRatelimitRequest (307-315)
  • CreateRoleRequest (408-414)
  • CreatePermissionRequest (453-458)
go/pkg/db/models_generated.go (4)
  • Identity (629-638)
  • Ratelimit (736-747)
  • Role (772-779)
  • Permission (704-712)
go/apps/api/routes/v2_keys_verify_key/200_test.go (1)
go/apps/api/openapi/gen.go (2)
  • Identity (161-173)
  • Meta (279-282)
go/pkg/testutil/seed/seed.go (6)
go/pkg/db/key_role_insert.sql_generated.go (1)
  • InsertKeyRoleParams (27-32)
go/pkg/db/key_permission_insert.sql_generated.go (1)
  • InsertKeyPermissionParams (27-33)
go/pkg/db/models_generated.go (5)
  • Ratelimit (736-747)
  • Identity (629-638)
  • Environment (618-627)
  • Role (772-779)
  • Permission (704-712)
go/pkg/db/role_insert.sql_generated.go (1)
  • InsertRoleParams (30-36)
go/pkg/db/role_permission_insert.sql_generated.go (1)
  • InsertRolePermissionParams (27-32)
go/pkg/db/permission_insert.sql_generated.go (1)
  • InsertPermissionParams (33-40)
go/apps/api/routes/v2_keys_add_roles/200_test.go (1)
go/pkg/testutil/seed/seed.go (1)
  • CreateRoleRequest (408-414)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: Build / Build
  • GitHub Check: Test API / API Test Local
  • GitHub Check: Test Go API Local / Test
  • GitHub Check: Analyze (javascript-typescript)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
go/pkg/testutil/seed/seed.go (1)

317-361: Masked insert error when both IdentityID and KeyID are set.

The second insert overwrites err; a first‑insert failure can be hidden.

-func (s *Seeder) CreateRatelimit(ctx context.Context, req CreateRatelimitRequest) db.Ratelimit {
+func (s *Seeder) CreateRatelimit(ctx context.Context, req CreateRatelimitRequest) db.Ratelimit {
   ratelimitID := uid.New(uid.RatelimitPrefix)
   createdAt := time.Now().UnixMilli()
-  var err error
-
   if req.IdentityID != nil {
-    err = db.Query.InsertIdentityRatelimit(ctx, s.DB.RW(), db.InsertIdentityRatelimitParams{
+    if err := db.Query.InsertIdentityRatelimit(ctx, s.DB.RW(), db.InsertIdentityRatelimitParams{
       ID:          ratelimitID,
       WorkspaceID: req.WorkspaceID,
       IdentityID:  sql.NullString{String: *req.IdentityID, Valid: true},
       Name:        req.Name,
       Limit:       req.Limit,
       Duration:    req.Duration,
       AutoApply:   req.AutoApply,
       CreatedAt:   createdAt,
-    })
+    }); err != nil {
+      require.NoError(s.t, err)
+    }
   }
 
   if req.KeyID != nil {
-    err = db.Query.InsertKeyRatelimit(ctx, s.DB.RW(), db.InsertKeyRatelimitParams{
+    if err := db.Query.InsertKeyRatelimit(ctx, s.DB.RW(), db.InsertKeyRatelimitParams{
       ID:          ratelimitID,
       WorkspaceID: req.WorkspaceID,
       KeyID:       sql.NullString{String: *req.KeyID, Valid: true},
       Name:        req.Name,
       Limit:       req.Limit,
       Duration:    req.Duration,
       AutoApply:   req.AutoApply,
       CreatedAt:   createdAt,
-    })
+    }); err != nil {
+      require.NoError(s.t, err)
+    }
   }
-
-  require.NoError(s.t, err)

Additionally fix:

  • Line 420 CreateRole: use uid.RolePrefix instead of uid.PermissionPrefix
  • Lines 462–463 CreatePermission: assertions should check req.Name and req.Slug respectively, not req.WorkspaceID
🧹 Nitpick comments (4)
go/apps/api/routes/v2_keys_add_roles/200_test.go (1)

139-142: Make assertion order‑independent to avoid flakes.

Response order isn’t guaranteed; compare as sets.

Based on learnings

-    roleNames := []string{res.Body.Data[0].Name, res.Body.Data[1].Name}
-    require.Equal(t, []string{"admin_idempotent", "editor_idempotent"}, roleNames)
+    roleNames := []string{res.Body.Data[0].Name, res.Body.Data[1].Name}
+    expected := []string{"admin_idempotent", "editor_idempotent"}
+    require.ElementsMatch(t, expected, roleNames)
go/pkg/testutil/seed/seed.go (1)

371-405: Reuse a single createdAt for deterministic returns.

Insert and return can diverge by milliseconds. Capture once and reuse.

-func (s *Seeder) CreateIdentity(ctx context.Context, req CreateIdentityRequest) db.Identity {
+func (s *Seeder) CreateIdentity(ctx context.Context, req CreateIdentityRequest) db.Identity {
+  createdAt := time.Now().UnixMilli()
   ...
-  err := db.Query.InsertIdentity(ctx, s.DB.RW(), db.InsertIdentityParams{
+  err := db.Query.InsertIdentity(ctx, s.DB.RW(), db.InsertIdentityParams{
     ID:          identityId,
     ExternalID:  req.ExternalID,
     WorkspaceID: req.WorkspaceID,
     Environment: "",
-    CreatedAt:   time.Now().UnixMilli(),
+    CreatedAt:   createdAt,
     Meta:        metaBytes,
   })
   ...
   return db.Identity{
     ID:          identityId,
     ExternalID:  req.ExternalID,
     WorkspaceID: req.WorkspaceID,
     Environment: "",
     Meta:        metaBytes,
     Deleted:     false,
-    CreatedAt:   time.Now().UnixMilli(),
+    CreatedAt:   createdAt,
     UpdatedAt:   sql.NullInt64{Valid: false},
   }
go/apps/api/routes/v2_keys_whoami/200_test.go (2)

101-105: Swap expected/actual in require.Equal.

Conventional order is expected, actual to get clearer diffs.

-    require.Equal(t, res.Body.Data.KeyId, keyID)
+    require.Equal(t, keyID, res.Body.Data.KeyId)

174-181: Optional: use test clock for time derivations.

Using h.Clock.Now() avoids wall‑clock flakiness in CI.

-    futureDate := time.Now().Add(24 * time.Hour).Truncate(time.Hour)
+    futureDate := h.Clock.Now().Add(24 * time.Hour).Truncate(time.Hour)
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c764837 and 2c8fd7d.

📒 Files selected for processing (13)
  • go/apps/api/routes/v2_identities_get_identity/200_test.go (1 hunks)
  • go/apps/api/routes/v2_keys_add_permissions/200_test.go (9 hunks)
  • go/apps/api/routes/v2_keys_add_roles/200_test.go (2 hunks)
  • go/apps/api/routes/v2_keys_get_key/200_test.go (2 hunks)
  • go/apps/api/routes/v2_keys_remove_permissions/200_test.go (7 hunks)
  • go/apps/api/routes/v2_keys_remove_permissions/404_test.go (2 hunks)
  • go/apps/api/routes/v2_keys_reroll_key/200_test.go (2 hunks)
  • go/apps/api/routes/v2_keys_verify_key/200_test.go (3 hunks)
  • go/apps/api/routes/v2_keys_verify_key/412_test.go (2 hunks)
  • go/apps/api/routes/v2_keys_verify_key/multilimit_test.go (5 hunks)
  • go/apps/api/routes/v2_keys_whoami/200_test.go (2 hunks)
  • go/pkg/testutil/http.go (1 hunks)
  • go/pkg/testutil/seed/seed.go (8 hunks)
🧰 Additional context used
🧬 Code graph analysis (12)
go/apps/api/routes/v2_keys_remove_permissions/404_test.go (1)
go/pkg/testutil/seed/seed.go (1)
  • CreatePermissionRequest (453-458)
go/apps/api/routes/v2_keys_verify_key/multilimit_test.go (1)
go/pkg/testutil/seed/seed.go (1)
  • CreateKeyRequest (188-208)
go/apps/api/routes/v2_identities_get_identity/200_test.go (2)
go/pkg/db/models_generated.go (1)
  • Identity (629-638)
go/apps/api/openapi/gen.go (1)
  • Identity (161-173)
go/apps/api/routes/v2_keys_add_roles/200_test.go (1)
go/pkg/testutil/seed/seed.go (1)
  • CreateRoleRequest (408-414)
go/apps/api/routes/v2_keys_whoami/200_test.go (1)
go/pkg/testutil/seed/seed.go (1)
  • CreateIdentityRequest (364-369)
go/apps/api/routes/v2_keys_get_key/200_test.go (1)
go/pkg/testutil/seed/seed.go (1)
  • CreateIdentityRequest (364-369)
go/apps/api/routes/v2_keys_verify_key/200_test.go (1)
go/apps/api/openapi/gen.go (2)
  • Identity (161-173)
  • Meta (279-282)
go/pkg/testutil/http.go (3)
go/apps/api/integration/harness.go (1)
  • Harness (34-44)
go/pkg/testutil/seed/seed.go (4)
  • CreateIdentityRequest (364-369)
  • CreateRatelimitRequest (307-315)
  • CreateRoleRequest (408-414)
  • CreatePermissionRequest (453-458)
go/pkg/db/models_generated.go (4)
  • Identity (629-638)
  • Ratelimit (736-747)
  • Role (772-779)
  • Permission (704-712)
go/apps/api/routes/v2_keys_reroll_key/200_test.go (1)
go/pkg/testutil/seed/seed.go (1)
  • CreateIdentityRequest (364-369)
go/pkg/testutil/seed/seed.go (7)
go/pkg/db/key_role_insert.sql_generated.go (1)
  • InsertKeyRoleParams (27-32)
go/pkg/db/key_permission_insert.sql_generated.go (1)
  • InsertKeyPermissionParams (27-33)
go/pkg/db/models_generated.go (5)
  • Ratelimit (736-747)
  • Identity (629-638)
  • Environment (618-627)
  • Role (772-779)
  • Permission (704-712)
go/pkg/uid/uid.go (2)
  • RatelimitPrefix (29-29)
  • PermissionPrefix (27-27)
go/pkg/db/role_insert.sql_generated.go (1)
  • InsertRoleParams (30-36)
go/pkg/db/role_permission_insert.sql_generated.go (1)
  • InsertRolePermissionParams (27-32)
go/pkg/db/permission_insert.sql_generated.go (1)
  • InsertPermissionParams (33-40)
go/apps/api/routes/v2_keys_remove_permissions/200_test.go (2)
go/pkg/testutil/seed/seed.go (1)
  • CreatePermissionRequest (453-458)
go/pkg/db/key_permission_insert.sql_generated.go (1)
  • InsertKeyPermissionParams (27-33)
go/apps/api/routes/v2_keys_add_permissions/200_test.go (1)
go/pkg/testutil/seed/seed.go (1)
  • CreatePermissionRequest (453-458)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (2)
  • GitHub Check: Test Go API Local / Test
  • GitHub Check: Build / Build
🔇 Additional comments (19)
go/apps/api/routes/v2_keys_add_roles/200_test.go (1)

98-116: LGTM on switching to struct return (admin.ID).

Correct adaptation to seeder changes; params align with db.InsertKeyRoleParams.

go/apps/api/routes/v2_keys_whoami/200_test.go (1)

49-70: LGTM on switching to identity struct and .ID.

Matches seeder changes and pointer usage &identity.ID is correct.

go/apps/api/routes/v2_keys_verify_key/412_test.go (2)

52-56: LGTM on IdentityID wiring.

Passing ptr.P(identity.ID) aligns with seeder changes.


70-75: LGTM on error detail checks.

Asserting presence of identity.ID and external ID is appropriate.

go/pkg/testutil/http.go (1)

221-235: Code changes verified—no call-site issues detected.

All call sites properly access the .ID field on returned db structs. Examples verified:

  • IdentityID: &identity.ID (v2_keys_whoami/200_test.go)
  • IdentityID: ptr.P(identity.ID) (v2_keys_verify_key/200_test.go)
  • Id: identity.ID (v2_keys_verify_key/200_test.go:685)

The test codebase correctly handles the return type changes. No fixes or refactoring needed.

go/apps/api/routes/v2_keys_remove_permissions/404_test.go (1)

49-61: LGTM!

The refactoring correctly updates the variable from permissionID to permission and accesses the ID via permission.ID. The change improves type safety and consistency with the broader PR objective.

go/apps/api/routes/v2_keys_reroll_key/200_test.go (1)

47-76: LGTM!

The identity variable is now captured as a full object and correctly referenced via identity.ID when constructing the key. This aligns with the PR's objective to return full structs from seeder functions.

go/apps/api/routes/v2_keys_get_key/200_test.go (1)

49-69: LGTM!

The identity object is correctly captured and its ID is properly accessed via identity.ID for the IdentityID field. This follows the consistent pattern established throughout the PR.

go/apps/api/routes/v2_keys_remove_permissions/200_test.go (2)

117-148: LGTM!

The permission objects are correctly captured and their IDs are properly accessed when inserting key-permission associations. The refactoring improves type safety while maintaining the same test logic.


336-384: LGTM!

All three permission objects are correctly created and their IDs are properly used in the database insert operations. The pattern is consistent with the other test cases in this file.

go/apps/api/routes/v2_identities_get_identity/200_test.go (1)

380-387: LGTM!

The identity object is captured and its ID is correctly used in the request. This change enables the test to access the internal identity ID when needed, which aligns with the PR's goal of returning full structs.

go/apps/api/routes/v2_keys_verify_key/200_test.go (2)

593-613: LGTM!

The identity object is correctly captured and its ID is properly used in the key creation. This enables the test to access identity fields if needed in the future.


642-685: LGTM!

The identity object is correctly captured and used in two ways: (1) setting IdentityID: ptr.P(identity.ID) when creating the key, and (2) asserting the response identity matches via identity.ID. The refactoring maintains test correctness while improving type safety.

go/apps/api/routes/v2_keys_verify_key/multilimit_test.go (2)

112-134: LGTM!

The identity object is correctly captured and its ID is properly used when creating the key. This pattern is consistently applied across multiple test cases in this file.


162-184: LGTM!

All identity objects throughout the multilimit tests are correctly captured and their IDs are properly accessed via identity.ID. The refactoring is consistent and maintains test correctness.

Also applies to: 217-239, 282-306, 392-414

go/apps/api/routes/v2_keys_add_permissions/200_test.go (4)

12-12: LGTM!

The ptr package import is correctly added to support the ptr.P() helper for creating pointer values for optional fields like Description.


61-96: LGTM!

The permission object is correctly captured with proper field initialization using ptr.P() for the description. The permission's name and ID are correctly accessed throughout the test, improving type safety and reducing the need for intermediate variables.


119-167: LGTM!

Both permission objects are correctly created and their names and IDs are properly accessed. The pattern is consistent with the single-permission test case and aligns with the PR's objectives.


248-301: LGTM!

The new permission object is correctly created and its name and ID are properly used in the request and assertions. The refactoring maintains test correctness while eliminating the need for separate permission ID variables.

@Flo4604
Copy link
Member

Flo4604 commented Oct 17, 2025

lgtm except the things rabbit commented

@mcstepp mcstepp requested a review from Flo4604 October 20, 2025 15:34
@graphite-app
Copy link

graphite-app bot commented Oct 21, 2025

TV gif. Steve Irwin the Crocodile Hunter looking down at a body of water, turns around and gives a double thumbs-up, mouthing 'that's good.' (Added via Giphy)

@graphite-app
Copy link

graphite-app bot commented Oct 21, 2025

Graphite Automations

"Post a GIF when PR approved" took an action on this PR • (10/21/25)

1 gif was posted to this PR based on Andreas Thomas's automation.

@mcstepp mcstepp added this pull request to the merge queue Oct 21, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 21, 2025
Merged via the queue into main with commit 4da93dd Oct 22, 2025
18 checks passed
@Flo4604 Flo4604 deleted the ENG-1921-cleanup-seeder-functions branch October 22, 2025 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cleanup seeder functions to return full structs instead of IDs

3 participants