Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.DS_Store
*.log
.claude/
.worktrees/
16 changes: 16 additions & 0 deletions src/client/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,22 @@ impl TestCasesClient<'_> {
let url = self.0.url(&format!("/v1/test-cases/{id}"));
self.0.delete(url).await
}

pub async fn media_upload_url(
&self,
test_case_id: &str,
filename: &str,
mime_type: &str,
) -> 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
}
}

impl PersonasClient<'_> {
Expand Down
14 changes: 14 additions & 0 deletions src/client/models/test_case.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,17 @@ fn truncate(s: &str, max: usize) -> String {
format!("{}...", end)
}
}

#[derive(Debug, Serialize)]
pub struct MediaUploadUrlRequest {
pub filename: String,
pub mime_type: String,
}

#[derive(Debug, Serialize, Deserialize)]
pub struct MediaUploadUrlResponse {
pub upload_url: String,
pub s3_key: String,
pub s3_bucket: String,
pub url_expires_in_seconds: i64,
}
22 changes: 22 additions & 0 deletions src/commands/test_cases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ pub enum TestCaseCommands {
Create(CreateArgs),
Update(UpdateArgs),
Delete(DeleteArgs),
#[command(name = "media-upload-url")]
MediaUploadUrl(MediaUploadUrlArgs),
}

impl TestCaseCommands {
Expand All @@ -33,6 +35,7 @@ impl TestCaseCommands {
Self::Create(_) => "create",
Self::Update(_) => "update",
Self::Delete(_) => "delete",
Self::MediaUploadUrl(_) => "media-upload-url",
}
}
}
Expand Down Expand Up @@ -125,6 +128,18 @@ pub struct DeleteArgs {
test_case_id: String,
}

#[derive(Args)]
pub struct MediaUploadUrlArgs {
/// Test case ID (8-char)
test_case_id: String,
/// Name of the file to upload
#[arg(long)]
filename: String,
/// MIME type of the file to upload
#[arg(long, default_value = "application/octet-stream")]
mime_type: String,
}
Comment thread
greptile-apps[bot] marked this conversation as resolved.

pub async fn execute(
cmd: TestCaseCommands,
client: &CovalClient,
Expand Down Expand Up @@ -285,6 +300,13 @@ pub async fn execute(
],
);
}
TestCaseCommands::MediaUploadUrl(args) => {
let result = client
.test_cases()
.media_upload_url(&args.test_case_id, &args.filename, &args.mime_type)
.await?;
emit_one_with_actions(ctx, "test-cases", operation, &result, vec![]);
}
}
Ok(())
}
Expand Down
Loading