LCOV - code coverage report
Current view: top level - compute_tools/src/http/routes - database_schema.rs (source / functions) Coverage Total Hit
Test: 07bee600374ccd486c69370d0972d9035964fe68.info Lines: 0.0 % 14 0
Test Date: 2025-02-20 13:11:02 Functions: 0.0 % 7 0

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

Generated by: LCOV version 2.1-beta