mirror of
				https://github.com/meilisearch/meilisearch.git
				synced 2025-11-04 01:46:28 +00:00 
			
		
		
		
	bug(lib): fix get dumps bad error code
This commit is contained in:
		@@ -1,3 +1,4 @@
 | 
			
		||||
#![allow(dead_code)]
 | 
			
		||||
use std::path::Path;
 | 
			
		||||
 | 
			
		||||
use actix_web::http::StatusCode;
 | 
			
		||||
@@ -88,6 +89,10 @@ impl Server {
 | 
			
		||||
    pub async fn tasks(&self) -> (Value, StatusCode) {
 | 
			
		||||
        self.service.get("/tasks").await
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    pub async fn get_dump_status(&self, uid: &str) -> (Value, StatusCode) {
 | 
			
		||||
        self.service.get(format!("/dumps/{}/status", uid)).await
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
pub fn default_settings(dir: impl AsRef<Path>) -> Opt {
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										22
									
								
								meilisearch-http/tests/dumps.rs
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								meilisearch-http/tests/dumps.rs
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,22 @@
 | 
			
		||||
#![allow(dead_code)]
 | 
			
		||||
mod common;
 | 
			
		||||
 | 
			
		||||
use crate::common::Server;
 | 
			
		||||
use serde_json::json;
 | 
			
		||||
 | 
			
		||||
#[actix_rt::test]
 | 
			
		||||
async fn get_unexisting_dump_status() {
 | 
			
		||||
    let server = Server::new().await;
 | 
			
		||||
 | 
			
		||||
    let (response, code) = server.get_dump_status("foobar").await;
 | 
			
		||||
    assert_eq!(code, 404);
 | 
			
		||||
 | 
			
		||||
    let expected_response = json!({
 | 
			
		||||
    "message": "Dump `foobar` not found.",
 | 
			
		||||
    "code": "dump_not_found",
 | 
			
		||||
    "type": "invalid_request",
 | 
			
		||||
    "link": "https://docs.meilisearch.com/errors#dump_not_found"
 | 
			
		||||
    });
 | 
			
		||||
 | 
			
		||||
    assert_eq!(response, expected_response);
 | 
			
		||||
}
 | 
			
		||||
@@ -59,10 +59,7 @@ impl ErrorCode for IndexControllerError {
 | 
			
		||||
            IndexControllerError::DocumentFormatError(e) => e.error_code(),
 | 
			
		||||
            IndexControllerError::MissingPayload(_) => Code::MissingPayload,
 | 
			
		||||
            IndexControllerError::PayloadTooLarge => Code::PayloadTooLarge,
 | 
			
		||||
            IndexControllerError::DumpError(DumpActorError::DumpAlreadyRunning) => {
 | 
			
		||||
                Code::DumpAlreadyInProgress
 | 
			
		||||
            }
 | 
			
		||||
            IndexControllerError::DumpError(_) => Code::DumpProcessFailed,
 | 
			
		||||
            IndexControllerError::DumpError(e) => e.error_code(),
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user