Skip to content

feat: add test-cases media upload-url CLI command (API parity)#87

Merged
callumreid merged 3 commits into
mainfrom
feat/cli-api-parity-testcases-media
Jul 2, 2026
Merged

feat: add test-cases media upload-url CLI command (API parity)#87
callumreid merged 3 commits into
mainfrom
feat/cli-api-parity-testcases-media

Conversation

@callumreid

@callumreid callumreid commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds media-upload-url subcommand to coval test-cases.

What's New

  • coval test-cases media-upload-url <id> --filename <name> [--mime-type <type>]

Generates a presigned S3 upload URL for attaching media to a test case.
Matches POST /v1/test-cases/{id}/media:upload-url.

Verification

  • cargo build ✓ - cargo test 90/90 ✓

Greptile Summary

Adds a media-upload-url subcommand to coval test-cases, providing API parity with POST /v1/test-cases/{id}/media:upload-url. The command generates a presigned S3 upload URL for attaching media to a test case.

  • New MediaUploadUrlArgs struct with test_case_id (positional), --filename (required), and --mime-type (optional, defaults to application/octet-stream), plus doc comments on all fields for --help output consistency.
  • New MediaUploadUrlRequest/MediaUploadUrlResponse model structs and a corresponding media_upload_url method on TestCasesClient.
  • .worktrees/ added to .gitignore to prevent accidental worktree commits.

Confidence Score: 5/5

Safe to merge — the change is a self-contained new subcommand with no modifications to existing logic.

The new command wires directly to a single new API endpoint with no shared state or side-effects on existing commands. Previous review feedback (unsafe default MIME type, missing help text, accidental worktree commit) has all been addressed in this revision.

No files require special attention.

Reviews (3): Last reviewed commit: "fix: address review comments" | Re-trigger Greptile

@coderabbitai

coderabbitai Bot commented Jun 26, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

This PR adds a media upload URL feature to the CLI: new MediaUploadUrlRequest/MediaUploadUrlResponse data models, a TestCasesClient::media_upload_url async method that posts to the /v1/test-cases/{test_case_id}/media:upload-url endpoint, and a new test-cases media-upload-url CLI subcommand with corresponding argument struct and execution dispatch. Additionally, .gitignore is updated to exclude the .worktrees/ directory.

Changes

Area Change
Data models Added MediaUploadUrlRequest and MediaUploadUrlResponse structs
Client Added TestCasesClient::media_upload_url async method
CLI Added MediaUploadUrl command variant, MediaUploadUrlArgs, operation mapping, and execute dispatch
Config Added .worktrees/ to .gitignore

Sequence Diagram(s)

sequenceDiagram
  participant CLI
  participant TestCaseCommands
  participant TestCasesClient
  participant API
  CLI->>TestCaseCommands: MediaUploadUrl(MediaUploadUrlArgs)
  TestCaseCommands->>TestCasesClient: media_upload_url(test_case_id, filename, mime_type)
  TestCasesClient->>API: POST media:upload-url (MediaUploadUrlRequest)
  API-->>TestCasesClient: MediaUploadUrlResponse
  TestCasesClient-->>TestCaseCommands: MediaUploadUrlResponse
  TestCaseCommands-->>CLI: emit_one_with_actions(response)
Loading

Suggested reviewers: borgesius

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding the test-cases media-upload-url CLI command for API parity.
Description check ✅ Passed The description is directly related and accurately describes the new subcommand, client method, models, and verification.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

Comment thread src/commands/test_cases.rs Outdated
Comment thread src/commands/test_cases.rs
Comment thread .worktrees/cli-parity Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🧹 Nitpick comments (2)
src/client/mod.rs (1)

498-512: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Inconsistent method signature vs. create/update pattern.

create() and update() take a pre-built request struct (req: models::CreateTestCaseRequest / models::UpdateTestCaseRequest), but media_upload_url instead takes raw scalar params (filename, mime_type) and builds the request struct internally. This diverges from the established pattern and makes the request struct's existence redundant for callers.

♻️ Proposed refactor for consistency
     pub async fn media_upload_url(
         &self,
         test_case_id: &str,
-        filename: &str,
-        mime_type: &str,
+        req: models::MediaUploadUrlRequest,
     ) -> Result<models::MediaUploadUrlResponse, ApiError> {
         let url = self
             .0
             .url(&format!("/v1/test-cases/{test_case_id}/media:upload-url"));
-        let req = models::MediaUploadUrlRequest {
-            filename: filename.to_string(),
-            mime_type: mime_type.to_string(),
-        };
         self.0.post(url, &req).await
     }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/client/mod.rs` around lines 498 - 512, `media_upload_url` is inconsistent
with the `create` and `update` API patterns because it accepts raw fields and
constructs `models::MediaUploadUrlRequest` internally. Refactor
`media_upload_url` to take a pre-built request struct argument, matching the
signatures of `create` and `update`, and keep the URL/post logic in
`Client::media_upload_url` unchanged aside from using the provided request
value.
src/commands/test_cases.rs (1)

303-309: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

No follow-up next actions offered for this command.

Every other mutating command (Create, Update, Delete) emits contextual next_actions (e.g., get/context), but MediaUploadUrl passes an empty vec![]. Consider adding at least next_actions::context("test-cases") (and possibly next_actions::get("test-cases", &args.test_case_id)) for consistency with the rest of the agent-facing UX.

♻️ Proposed fix
             emit_one_with_actions(ctx, "test-cases", operation, &result, vec![]);
+            emit_one_with_actions(
+                ctx,
+                "test-cases",
+                operation,
+                &result,
+                vec![
+                    next_actions::get("test-cases", &args.test_case_id).primary(),
+                    next_actions::context("test-cases"),
+                ],
+            );
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commands/test_cases.rs` around lines 303 - 309, The MediaUploadUrl branch
in test_cases.rs emits no follow-up actions, unlike the other mutating commands.
Update the TestCaseCommands::MediaUploadUrl handling to pass contextual
next_actions through emit_one_with_actions, using the same pattern as
Create/Update/Delete in this module; include at least
next_actions::context("test-cases") and consider next_actions::get("test-cases",
&args.test_case_id) for consistency. Keep the change localized to the
MediaUploadUrl match arm and preserve the existing client call and result
emission flow.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@src/client/mod.rs`:
- Around line 498-512: `media_upload_url` is inconsistent with the `create` and
`update` API patterns because it accepts raw fields and constructs
`models::MediaUploadUrlRequest` internally. Refactor `media_upload_url` to take
a pre-built request struct argument, matching the signatures of `create` and
`update`, and keep the URL/post logic in `Client::media_upload_url` unchanged
aside from using the provided request value.

In `@src/commands/test_cases.rs`:
- Around line 303-309: The MediaUploadUrl branch in test_cases.rs emits no
follow-up actions, unlike the other mutating commands. Update the
TestCaseCommands::MediaUploadUrl handling to pass contextual next_actions
through emit_one_with_actions, using the same pattern as Create/Update/Delete in
this module; include at least next_actions::context("test-cases") and consider
next_actions::get("test-cases", &args.test_case_id) for consistency. Keep the
change localized to the MediaUploadUrl match arm and preserve the existing
client call and result emission flow.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4d05d207-606a-4ba6-8ab9-f34b40556fea

📥 Commits

Reviewing files that changed from the base of the PR and between 61d1d1d and 19a6f20.

📒 Files selected for processing (4)
  • .gitignore
  • src/client/mod.rs
  • src/client/models/test_case.rs
  • src/commands/test_cases.rs

@callumreid

Copy link
Copy Markdown
Contributor Author

🟢

@borgesius borgesius left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks reasonable. The media upload-url request/response fields match the backend schema and the command is a small additive wrapper around the new endpoint.

@callumreid callumreid merged commit ba35ed7 into main Jul 2, 2026
8 checks passed
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