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 Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/gitforge-api/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ prometheus = "0.14"
hyper = "1.5"
tempfile = "3"
gitforge-review = { path = "../gitforge-review" }
sqlx = { workspace = true }

[lints]
workspace = true
43 changes: 43 additions & 0 deletions crates/gitforge-api/tests/ci_routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,49 @@ async fn pipeline_run_endpoints_scoped_and_expose_jobs_with_receipts() {
assert_eq!(missing["error"], "not_found");
}

#[tokio::test]
async fn pipeline_run_list_treats_blank_optional_finish_time_as_null() {
let f = seed().await;
sqlx::query("UPDATE pipeline_runs SET finished_at = '' WHERE id = ?")
.bind(f.run_id.to_string())
.execute(f.pool.pool())
.await
.unwrap();

let (status, runs) = request_json(
f.app,
"GET",
"/api/pipeline-runs",
Some(&f.owner_token),
None,
)
.await;
assert_eq!(status, StatusCode::OK, "response: {runs}");
assert_eq!(runs.as_array().unwrap().len(), 1);
assert_eq!(runs[0]["finished_at"], Value::Null);
}

#[tokio::test]
async fn pipeline_run_list_still_rejects_malformed_nonblank_finish_time() {
let f = seed().await;
sqlx::query("UPDATE pipeline_runs SET finished_at = 'not-a-timestamp' WHERE id = ?")
.bind(f.run_id.to_string())
.execute(f.pool.pool())
.await
.unwrap();

let (status, body) = request_json(
f.app,
"GET",
"/api/pipeline-runs",
Some(&f.owner_token),
None,
)
.await;
assert_eq!(status, StatusCode::INTERNAL_SERVER_ERROR);
assert_eq!(body["error"], "database_error");
}

#[tokio::test]
async fn submit_job_rejects_invalid_payloads() {
let f = seed().await;
Expand Down
1 change: 1 addition & 0 deletions crates/gitforge-db/src/queries.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ fn parse_optional_timestamp_column(
.try_get(column)
.map_err(|error| Error::database(format!("invalid {column} column: {error}")))?;
value
.and_then(|value| (!value.trim().is_empty()).then_some(value))
.map(|value| {
DateTime::parse_from_rfc3339(&value)
.map(|date| date.with_timezone(&Utc))
Expand Down
Loading