LCOV - code coverage report
Current view: top level - compute_tools/src/http/routes - database_schema.rs (source / functions) Coverage Total Hit
Test: 5fe7fa8d483b39476409aee736d6d5e32728bfac.info Lines: 0.0 % 14 0
Test Date: 2025-03-12 16:10:49 Functions: 0.0 % 7 0

            Line data    Source code
       1              : use std::sync::Arc;
       2              : 
       3              : use axum::body::Body;
       4              : use axum::extract::State;
       5              : use axum::response::Response;
       6              : use http::StatusCode;
       7              : use http::header::CONTENT_TYPE;
       8              : use serde::Deserialize;
       9              : 
      10              : use crate::catalog::{SchemaDumpError, get_database_schema};
      11              : use crate::compute::ComputeNode;
      12              : use crate::http::JsonResponse;
      13              : use crate::http::extract::Query;
      14              : 
      15            0 : #[derive(Debug, Clone, Deserialize)]
      16              : pub(in crate::http) struct DatabaseSchemaParams {
      17              :     database: String,
      18              : }
      19              : 
      20              : /// Get a schema dump of the requested database.
      21            0 : pub(in crate::http) async fn get_schema_dump(
      22            0 :     params: Query<DatabaseSchemaParams>,
      23            0 :     State(compute): State<Arc<ComputeNode>>,
      24            0 : ) -> Response {
      25            0 :     match get_database_schema(&compute, &params.database).await {
      26            0 :         Ok(schema) => Response::builder()
      27            0 :             .status(StatusCode::OK)
      28            0 :             .header(CONTENT_TYPE.as_str(), "application/json")
      29            0 :             .body(Body::from_stream(schema))
      30            0 :             .unwrap(),
      31              :         Err(SchemaDumpError::DatabaseDoesNotExist) => {
      32            0 :             JsonResponse::error(StatusCode::NOT_FOUND, SchemaDumpError::DatabaseDoesNotExist)
      33              :         }
      34            0 :         Err(e) => JsonResponse::error(StatusCode::INTERNAL_SERVER_ERROR, e),
      35              :     }
      36            0 : }
        

Generated by: LCOV version 2.1-beta