Skip to content

Commit

Permalink
Use default if response is empty
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Schmitz authored and rtyler committed Dec 13, 2023
1 parent b4c055d commit fee96a7
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions crates/deltalake-core/src/data_catalog/unity/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub enum ListTableSummariesResponse {
/// Successful response
Success {
/// Basic table infos
#[serde(default)]
tables: Vec<TableSummary>,
/// Continuation token
next_page_token: Option<String>,
Expand Down Expand Up @@ -441,6 +442,16 @@ pub(crate) mod tests {
}
"#;

pub(crate) const LIST_TABLES: &str = r#"
{
"tables": [{
"full_name": "catalog.schema.table_name",
"table_type": "MANAGED"
}]
}
"#;
pub(crate) const LIST_TABLES_EMPTY: &str = "{}";

#[test]
fn test_responses() {
let list_schemas: Result<ListSchemasResponse, _> =
Expand All @@ -458,6 +469,21 @@ pub(crate) mod tests {
GetTableResponse::Success { .. }
));

let list_tables: Result<ListTableSummariesResponse, _> = serde_json::from_str(LIST_TABLES);
assert!(list_tables.is_ok());
assert!(matches!(
list_tables.unwrap(),
ListTableSummariesResponse::Success { .. }
));

let list_tables: Result<ListTableSummariesResponse, _> =
serde_json::from_str(LIST_TABLES_EMPTY);
assert!(list_tables.is_ok());
assert!(matches!(
list_tables.unwrap(),
ListTableSummariesResponse::Success { .. }
));

let get_schema: Result<GetSchemaResponse, _> = serde_json::from_str(GET_SCHEMA_RESPONSE);
assert!(get_schema.is_ok());
assert!(matches!(get_schema.unwrap(), GetSchemaResponse::Success(_)))
Expand Down

0 comments on commit fee96a7

Please sign in to comment.