116: Add tests for every plateform + clippy r=MarinPostma a=curquiza



Co-authored-by: Clémentine Urquizar <clementine@meilisearch.com>
This commit is contained in:
bors[bot] 2021-04-27 11:07:58 +00:00 committed by GitHub
commit 7055384aeb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 74 additions and 29 deletions

View File

@ -13,12 +13,54 @@ env:
jobs: jobs:
tests: tests:
name: Tests on ${{ matrix.os }}
runs-on: ubuntu-latest runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-18.04, macos-latest]
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Build - name: Run cargo check without any default features
run: cargo build --verbose uses: actions-rs/cargo@v1
- name: Run tests with:
run: cargo test --verbose command: check
args: --no-default-features
- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: test
args: --locked --release
# We don't run test on Windows since we get the following error: There is not enough space on the disk.
check-on-windows:
name: Cargo check on Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- name: Run cargo check without any default features
uses: actions-rs/cargo@v1
with:
command: check
args: --no-default-features
- name: Run cargo check with all default features
uses: actions-rs/cargo@v1
with:
command: check
clippy:
name: Run Clippy
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
components: clippy
- name: Run cargo clippy
uses: actions-rs/cargo@v1
with:
command: clippy
args: --all-targets -- --deny warnings

View File

@ -1,3 +1,8 @@
status = ['tests'] status = [
'Tests on ubuntu-18.04',
'Tests on macos-latest',
'Cargo check on Windows',
'Run Clippy'
]
# 3 hours timeout # 3 hours timeout
timeout-sec = 10800 timeout-sec = 10800

View File

@ -162,7 +162,7 @@ impl Index {
); );
for (_id, obkv) in self.documents(&rtxn, documents_ids)? { for (_id, obkv) in self.documents(&rtxn, documents_ids)? {
let document = make_document(&all_attributes, &fields_ids_map, obkv.clone())?; let document = make_document(&all_attributes, &fields_ids_map, obkv)?;
let formatted = compute_formatted( let formatted = compute_formatted(
&fields_ids_map, &fields_ids_map,
obkv, obkv,

View File

@ -197,7 +197,7 @@ impl<S: IndexStore + Sync + Send> IndexActor<S> {
.map_err(|e| IndexError::Error(e.into())) .map_err(|e| IndexError::Error(e.into()))
} }
*self.processing.write().await = Some(meta.index_uuid().clone()); *self.processing.write().await = Some(*meta.index_uuid());
let result = get_result(self, meta, data).await; let result = get_result(self, meta, data).await;
*self.processing.write().await = None; *self.processing.write().await = None;

View File

@ -13,6 +13,7 @@ use uuid::Uuid;
use crate::helpers::EnvSizer; use crate::helpers::EnvSizer;
use crate::index_controller::updates::*; use crate::index_controller::updates::*;
#[allow(clippy::upper_case_acronyms)]
type BEU64 = heed::zerocopy::U64<heed::byteorder::BE>; type BEU64 = heed::zerocopy::U64<heed::byteorder::BE>;
#[derive(Clone)] #[derive(Clone)]

View File

@ -1,5 +1,4 @@
use std::collections::BTreeMap; use std::collections::BTreeMap;
use std::iter::FromIterator;
use actix_web::get; use actix_web::get;
use actix_web::web; use actix_web::web;
@ -33,7 +32,7 @@ impl From<IndexStats> for IndexStatsResponse {
Self { Self {
number_of_documents: stats.number_of_documents, number_of_documents: stats.number_of_documents,
is_indexing: stats.is_indexing, is_indexing: stats.is_indexing,
fields_distribution: BTreeMap::from_iter(stats.fields_distribution.into_iter()), fields_distribution: stats.fields_distribution.into_iter().collect(),
} }
} }
} }

View File

@ -47,7 +47,7 @@ impl Index<'_> {
update_id as u64 update_id as u64
} }
pub async fn create<'a>(&'a self, primary_key: Option<&str>) -> (Value, StatusCode) { pub async fn create(& self, primary_key: Option<&str>) -> (Value, StatusCode) {
let body = json!({ let body = json!({
"uid": self.uid, "uid": self.uid,
"primaryKey": primary_key, "primaryKey": primary_key,

View File

@ -44,7 +44,7 @@ impl Server {
} }
/// Returns a view to an index. There is no guarantee that the index exists. /// Returns a view to an index. There is no guarantee that the index exists.
pub fn index<'a>(&'a self, uid: impl AsRef<str>) -> Index<'a> { pub fn index(& self, uid: impl AsRef<str>) -> Index<'_> {
Index { Index {
uid: encode(uid.as_ref()), uid: encode(uid.as_ref()),
service: &self.service, service: &self.service,

View File

@ -8,13 +8,13 @@ pub struct Service(pub Data);
impl Service { impl Service {
pub async fn post(&self, url: impl AsRef<str>, body: Value) -> (Value, StatusCode) { pub async fn post(&self, url: impl AsRef<str>, body: Value) -> (Value, StatusCode) {
let mut app = test::init_service(create_app!(&self.0, true)).await; let app = test::init_service(create_app!(&self.0, true)).await;
let req = test::TestRequest::post() let req = test::TestRequest::post()
.uri(url.as_ref()) .uri(url.as_ref())
.set_json(&body) .set_json(&body)
.to_request(); .to_request();
let res = test::call_service(&mut app, req).await; let res = test::call_service(&app, req).await;
let status_code = res.status(); let status_code = res.status();
let body = test::read_body(res).await; let body = test::read_body(res).await;
@ -28,14 +28,14 @@ impl Service {
url: impl AsRef<str>, url: impl AsRef<str>,
body: impl AsRef<str>, body: impl AsRef<str>,
) -> (Value, StatusCode) { ) -> (Value, StatusCode) {
let mut app = test::init_service(create_app!(&self.0, true)).await; let app = test::init_service(create_app!(&self.0, true)).await;
let req = test::TestRequest::post() let req = test::TestRequest::post()
.uri(url.as_ref()) .uri(url.as_ref())
.set_payload(body.as_ref().to_string()) .set_payload(body.as_ref().to_string())
.insert_header(("content-type", "application/json")) .insert_header(("content-type", "application/json"))
.to_request(); .to_request();
let res = test::call_service(&mut app, req).await; let res = test::call_service(&app, req).await;
let status_code = res.status(); let status_code = res.status();
let body = test::read_body(res).await; let body = test::read_body(res).await;
@ -44,10 +44,10 @@ impl Service {
} }
pub async fn get(&self, url: impl AsRef<str>) -> (Value, StatusCode) { pub async fn get(&self, url: impl AsRef<str>) -> (Value, StatusCode) {
let mut app = test::init_service(create_app!(&self.0, true)).await; let app = test::init_service(create_app!(&self.0, true)).await;
let req = test::TestRequest::get().uri(url.as_ref()).to_request(); let req = test::TestRequest::get().uri(url.as_ref()).to_request();
let res = test::call_service(&mut app, req).await; let res = test::call_service(&app, req).await;
let status_code = res.status(); let status_code = res.status();
let body = test::read_body(res).await; let body = test::read_body(res).await;
@ -56,13 +56,13 @@ impl Service {
} }
pub async fn put(&self, url: impl AsRef<str>, body: Value) -> (Value, StatusCode) { pub async fn put(&self, url: impl AsRef<str>, body: Value) -> (Value, StatusCode) {
let mut app = test::init_service(create_app!(&self.0, true)).await; let app = test::init_service(create_app!(&self.0, true)).await;
let req = test::TestRequest::put() let req = test::TestRequest::put()
.uri(url.as_ref()) .uri(url.as_ref())
.set_json(&body) .set_json(&body)
.to_request(); .to_request();
let res = test::call_service(&mut app, req).await; let res = test::call_service(&app, req).await;
let status_code = res.status(); let status_code = res.status();
let body = test::read_body(res).await; let body = test::read_body(res).await;
@ -71,10 +71,10 @@ impl Service {
} }
pub async fn delete(&self, url: impl AsRef<str>) -> (Value, StatusCode) { pub async fn delete(&self, url: impl AsRef<str>) -> (Value, StatusCode) {
let mut app = test::init_service(create_app!(&self.0, true)).await; let app = test::init_service(create_app!(&self.0, true)).await;
let req = test::TestRequest::delete().uri(url.as_ref()).to_request(); let req = test::TestRequest::delete().uri(url.as_ref()).to_request();
let res = test::call_service(&mut app, req).await; let res = test::call_service(&app, req).await;
let status_code = res.status(); let status_code = res.status();
let body = test::read_body(res).await; let body = test::read_body(res).await;

View File

@ -55,10 +55,8 @@ async fn list_multiple_indexes() {
assert_eq!(arr.len(), 2); assert_eq!(arr.len(), 2);
assert!(arr assert!(arr
.iter() .iter()
.find(|entry| entry["uid"] == "test" && entry["primaryKey"] == Value::Null) .any(|entry| entry["uid"] == "test" && entry["primaryKey"] == Value::Null));
.is_some());
assert!(arr assert!(arr
.iter() .iter()
.find(|entry| entry["uid"] == "test1" && entry["primaryKey"] == "key") .any(|entry| entry["uid"] == "test1" && entry["primaryKey"] == "key"));
.is_some());
} }

View File

@ -35,7 +35,7 @@ async fn perform_snapshot() {
let snapshot_path = snapshot_dir let snapshot_path = snapshot_dir
.path() .path()
.to_owned() .to_owned()
.join(format!("db.snapshot")); .join("db.snapshot".to_string());
let options = Opt { let options = Opt {
import_snapshot: Some(snapshot_path), import_snapshot: Some(snapshot_path),