Skip to content

[AE-200] Add integration tests for PUT /links update endpoint#6

Merged
m3lc merged 2 commits intomainfrom
260310-new-spec-22048b
Mar 16, 2026
Merged

[AE-200] Add integration tests for PUT /links update endpoint#6
m3lc merged 2 commits intomainfrom
260310-new-spec-22048b

Conversation

@karansuraj
Copy link
Copy Markdown
Collaborator

@karansuraj karansuraj commented Mar 11, 2026

Summary

  • Adds PUT update tests to links.hurl: happy path, invalid URL (400), and non-existent link (404)
  • Tests use the existing link created by the POST test and captured urlId

Test plan

  • Run hurl --test --variables-file vars-dev.env links.hurl after link-shortener and ayrshare PRs are deployed

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features
    • Added the ability to update short link URLs via a new update endpoint.
  • Bug Fixes / Improvements
    • Added proper error responses for invalid update requests (400) and for attempts to update non-existent links (404).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: ba26efda-b2f0-4a41-acad-47dcb0542410

📥 Commits

Reviewing files that changed from the base of the PR and between 6bfa464 and 031c465.

📒 Files selected for processing (1)
  • links.hurl
🚧 Files skipped from review as they are similar to previous changes (1)
  • links.hurl

📝 Walkthrough

Walkthrough

Added three PUT test scenarios for /links/{{urlId}}: successful update (200, validates id and URL fields), invalid URL input (400 with code 126), and non-existent link (404 with error code 418). The three blocks are duplicated in the file.

Changes

Cohort / File(s) Summary
PUT endpoint test scenarios
links.hurl
Added tests for updating short links: success (200) validating status, id match, originalUrl/shortUrl and updated fields; invalid URL case (400, code 126); non-existent link case (404, error code 418). Added blocks appear duplicated.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 I nudged the links to make them new,
PUT hopped in and changed their view,
200 smiled, 400 frowned, 404 roamed,
Two copies now sit in the code's home,
A rabbit giggles—fix one, leave one alone. 🥕

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding integration tests for the PUT /links update endpoint, which matches the file additions in links.hurl.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 260310-new-spec-22048b

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

Copy link
Copy Markdown

@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: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@links.hurl`:
- Around line 143-149: The test uses a fixed missing ID in the PUT request ("PUT
{{BASE_URL}}/links/nonexistent123") which can collide with a real record; change
it to generate a per-run unique missing ID (e.g., append a timestamp or UUID) or
derive a guaranteed-nonexistent id from the existing template variable (e.g.,
"{{urlId}}-missing-<timestamp>" or "{{urlId}}-uuid") before issuing the PUT to
/links/:id so the 404 check is stable; update the request URL to use that
generated value while leaving the payload and Authorization intact.
- Around line 130-141: After asserting the PUT with invalid "url" returns HTTP
400 and code 126, add a follow-up GET to the same endpoint (GET
{{BASE_URL}}/links/{{urlId}}) and assert the resource was not mutated by
verifying jsonpath "$.originalUrl" == "https://www.ayrshare.com/updated"; this
ensures the failed update is side-effect free for the link identified by urlId.
- Around line 121-127: The assertion "jsonpath \"$.shortUrl\" exists" is too
weak; change it to assert the returned shortUrl equals the previously stored
short URL variable (e.g. jsonpath "$.shortUrl" == "{{shortUrl}}") so the update
endpoint cannot return a different short link; update the assertion that uses
the jsonpath expression for "$.shortUrl" to compare against the existing
template variable ({{shortUrl}}) tied to the original link rather than merely
checking existence.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 50363003-5725-4ead-8e25-24748505ab89

📥 Commits

Reviewing files that changed from the base of the PR and between 6089b3e and 6bfa464.

📒 Files selected for processing (1)
  • links.hurl

Comment thread links.hurl Outdated
Comment thread links.hurl
Comment thread links.hurl
- Assert shortUrl contains urlId instead of just exists
- Add GET after failed 400 PUT to verify no side effects
- Replace hardcoded nonexistent123 with zZzZzZ_no_match
- Assert error codes (126, 418) on failure responses

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@m3lc m3lc merged commit 92dc84a into main Mar 16, 2026
1 check passed
@m3lc m3lc deleted the 260310-new-spec-22048b branch March 16, 2026 13:54
@karansuraj karansuraj restored the 260310-new-spec-22048b branch March 17, 2026 14:48
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.

2 participants