90: restore version route r=MarinPostma a=MarinPostma

close #74


Co-authored-by: mpostma <postma.marin@protonmail.com>
This commit is contained in:
bors[bot] 2021-03-16 13:53:23 +00:00 committed by GitHub
commit c6dbd81823
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 24 additions and 3 deletions

2
Cargo.lock generated
View File

@ -1786,7 +1786,7 @@ dependencies = [
[[package]] [[package]]
name = "meilisearch-http" name = "meilisearch-http"
version = "0.17.0" version = "0.21.0-alpha"
dependencies = [ dependencies = [
"actix-cors", "actix-cors",
"actix-http 3.0.0-beta.4", "actix-http 3.0.0-beta.4",

View File

@ -4,7 +4,7 @@ description = "MeiliSearch HTTP server"
edition = "2018" edition = "2018"
license = "MIT" license = "MIT"
name = "meilisearch-http" name = "meilisearch-http"
version = "0.17.0" version = "0.21.0-alpha"
[[bin]] [[bin]]
name = "meilisearch" name = "meilisearch"
path = "src/main.rs" path = "src/main.rs"

View File

@ -56,5 +56,9 @@ struct VersionResponse {
#[get("/version", wrap = "Authentication::Private")] #[get("/version", wrap = "Authentication::Private")]
async fn get_version() -> HttpResponse { async fn get_version() -> HttpResponse {
todo!() HttpResponse::Ok().json(VersionResponse {
commit_sha: env!("VERGEN_SHA").to_string(),
build_date: env!("VERGEN_BUILD_TIMESTAMP").to_string(),
pkg_version: env!("CARGO_PKG_VERSION").to_string(),
})
} }

View File

@ -69,4 +69,8 @@ impl Server {
pub async fn list_indexes(&self) -> (Value, StatusCode) { pub async fn list_indexes(&self) -> (Value, StatusCode) {
self.service.get("/indexes").await self.service.get("/indexes").await
} }
pub async fn version(&self) -> (Value, StatusCode) {
self.service.get("/version").await
}
} }

View File

@ -4,6 +4,7 @@ mod index;
mod search; mod search;
mod settings; mod settings;
mod updates; mod updates;
mod stats;
// Tests are isolated by features in different modules to allow better readability, test // Tests are isolated by features in different modules to allow better readability, test
// targetability, and improved incremental compilation times. // targetability, and improved incremental compilation times.

View File

@ -0,0 +1,12 @@
use crate::common::Server;
#[actix_rt::test]
async fn get_settings_unexisting_index() {
let server = Server::new().await;
let (response, code) = server.version().await;
assert_eq!(code, 200);
let version = response.as_object().unwrap();
assert!(version.get("commitSha").is_some());
assert!(version.get("buildDate").is_some());
assert!(version.get("pkgVersion").is_some());
}