Skip to content

chore: enhance desiredrelease postgres tests#891

Merged
adityachoudhari26 merged 5 commits intomainfrom
enhance-desired-release-postgres-tests
Mar 30, 2026
Merged

chore: enhance desiredrelease postgres tests#891
adityachoudhari26 merged 5 commits intomainfrom
enhance-desired-release-postgres-tests

Conversation

@adityachoudhari26
Copy link
Copy Markdown
Member

@adityachoudhari26 adityachoudhari26 commented Mar 30, 2026

Summary by CodeRabbit

  • Tests

    • Expanded DB-backed integration tests for core data retrieval and variable resolution; added many new scenarios and assertions.
  • Chores

    • CI updated to run additional database-backed test jobs.
    • Removed a redundant internal method implementation to simplify behavior.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 30, 2026

Warning

Rate limit exceeded

@adityachoudhari26 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 11 minutes and 35 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 11 minutes and 35 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 913dcb9a-cccd-4fb5-beed-6434cc55dbb5

📥 Commits

Reviewing files that changed from the base of the PR and between aa23a92 and 3560fde.

📒 Files selected for processing (3)
  • apps/workspace-engine/svc/controllers/desiredrelease/getters_postgres.go
  • apps/workspace-engine/svc/controllers/desiredrelease/getters_postgres_test.go
  • apps/workspace-engine/svc/controllers/desiredrelease/variableresolver/getters_postgres_test.go
📝 Walkthrough

Walkthrough

Enabled DB-backed integration tests in CI, removed the Postgres-backed GetCurrentRelease method, and refactored/expanded PostgreSQL-backed tests for desiredrelease and variableresolver with fixtures, subtests, and broader scenario coverage.

Changes

Cohort / File(s) Summary
CI Workflow
.github/workflows/apps-workspace-engine.yaml
Activated DB-backed test step: sets POSTGRES_URL, USE_DATABASE_BACKING=1, SERVICES=none and runs go test -race for ./pkg/db/... and ./svc/controllers/....
Removed Method
apps/workspace-engine/svc/controllers/desiredrelease/getters_postgres.go
Removed (*PostgresGetter).GetCurrentRelease implementation that queried releases and returned formatted release data.
DesiredRelease Tests
apps/workspace-engine/svc/controllers/desiredrelease/getters_postgres_test.go
Replaced zero-value getter usage with newGetter helper; refactored tests into subtests and expanded scenarios across candidate versions, deployment/resource variables, policy skips, approval records, release-target existence, and added scope validation test.
VariableResolver Tests
apps/workspace-engine/svc/controllers/desiredrelease/variableresolver/getters_postgres_test.go
Added new DB-backed test suite: conditional DB enabling, fixture setup/cleanup, and tests for relationship rules, candidate loading (resource/deployment/environment), and entity-by-ID retrieval with metadata checks.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~30 minutes

Possibly related PRs

Suggested reviewers

  • jsbroks

Poem

🐰 I dug a tunnel through code and test,

found fixtures, subtests, and a DB nest,
Removed a method, planted a seed,
CI now wakes to integration heed,
Hops of green where coverage rests.

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 6.25% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title describes test enhancements, but the PR also removes a method implementation and modifies workflow configuration, which are functional changes not captured by the title. Clarify whether this PR's primary purpose is test enhancement or refactoring. Consider a more specific title if the method removal is significant, such as 'refactor: remove GetCurrentRelease and enhance desiredrelease tests'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch enhance-desired-release-postgres-tests

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
Copy Markdown
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.

🧹 Nitpick comments (2)
apps/workspace-engine/svc/controllers/desiredrelease/variableresolver/getters_postgres_test.go (1)

140-166: Make the workspace-filter subtest self-contained to avoid vacuous pass.

At Line 160-Line 165, this can pass even if no same-workspace rules are returned. Consider inserting one same-workspace rule in this subtest and asserting it is returned while the other-workspace rule is excluded.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/workspace-engine/svc/controllers/desiredrelease/variableresolver/getters_postgres_test.go`
around lines 140 - 166, The subtest "does not return rules from other
workspaces" is vacuous because it only inserts an other-workspace rule; update
the test to insert an additional relationship_rule row tied to f.workspaceID
(e.g., a rule with reference "same.ref") before calling
getter.GetRelationshipRules(ctx, f.workspaceID), then assert that the returned
rules include the "same.ref" rule and do not include "other.ref"; ensure you add
matching cleanup for the inserted same-workspace rule and keep using
getter.GetRelationshipRules and the existing pool.Exec/require.NoError pattern
so the assertions meaningfully verify workspace filtering.
apps/workspace-engine/svc/controllers/desiredrelease/getters_postgres_test.go (1)

489-509: Avoid cross-subtest data coupling in aggregation assertions.

Both subtests depend on rows inserted by earlier subtests in the same parent test. Please make each subtest create its own prerequisites so it remains reliable when run independently.

Also applies to: 568-580

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In
`@apps/workspace-engine/svc/controllers/desiredrelease/getters_postgres_test.go`
around lines 489 - 509, The subtests are relying on rows inserted by other
subtests, causing cross-test coupling; inside each subtest (e.g., the "null
environment and resource matches any target" case) insert its own prerequisite
rows instead of depending on earlier inserts: create distinct policy_skip rows
for the targeted skip and the global skip via pool.Exec with fresh UUIDs, call
getter.GetPolicySkips(versionID.String(), f.environmentID.String(),
f.resourceID.String()) and assert the exact expected count (or validate by ID)
rather than using a >= that assumes prior state; apply the same isolation change
to the other related subtest that asserts skips (the block around the later
assertion) so each subtest is self-contained and deterministic.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Nitpick comments:
In
`@apps/workspace-engine/svc/controllers/desiredrelease/getters_postgres_test.go`:
- Around line 489-509: The subtests are relying on rows inserted by other
subtests, causing cross-test coupling; inside each subtest (e.g., the "null
environment and resource matches any target" case) insert its own prerequisite
rows instead of depending on earlier inserts: create distinct policy_skip rows
for the targeted skip and the global skip via pool.Exec with fresh UUIDs, call
getter.GetPolicySkips(versionID.String(), f.environmentID.String(),
f.resourceID.String()) and assert the exact expected count (or validate by ID)
rather than using a >= that assumes prior state; apply the same isolation change
to the other related subtest that asserts skips (the block around the later
assertion) so each subtest is self-contained and deterministic.

In
`@apps/workspace-engine/svc/controllers/desiredrelease/variableresolver/getters_postgres_test.go`:
- Around line 140-166: The subtest "does not return rules from other workspaces"
is vacuous because it only inserts an other-workspace rule; update the test to
insert an additional relationship_rule row tied to f.workspaceID (e.g., a rule
with reference "same.ref") before calling getter.GetRelationshipRules(ctx,
f.workspaceID), then assert that the returned rules include the "same.ref" rule
and do not include "other.ref"; ensure you add matching cleanup for the inserted
same-workspace rule and keep using getter.GetRelationshipRules and the existing
pool.Exec/require.NoError pattern so the assertions meaningfully verify
workspace filtering.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 65f56fe6-0d31-4f16-bbab-deb3f2cdac9a

📥 Commits

Reviewing files that changed from the base of the PR and between 2b2235e and 4e8f5ec.

📒 Files selected for processing (4)
  • .github/workflows/apps-workspace-engine.yaml
  • apps/workspace-engine/svc/controllers/desiredrelease/getters_postgres.go
  • apps/workspace-engine/svc/controllers/desiredrelease/getters_postgres_test.go
  • apps/workspace-engine/svc/controllers/desiredrelease/variableresolver/getters_postgres_test.go
💤 Files with no reviewable changes (1)
  • apps/workspace-engine/svc/controllers/desiredrelease/getters_postgres.go

@adityachoudhari26 adityachoudhari26 merged commit 179c431 into main Mar 30, 2026
9 of 10 checks passed
@adityachoudhari26 adityachoudhari26 deleted the enhance-desired-release-postgres-tests branch March 30, 2026 20:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant