mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-14 17:02:49 +03:00
Lint tests too, and suppress some warnings. (#622)
`test_each::path` always gives us a `PathBuf` even if we don't want one, so we need to suppress the associated warning. V3_GIT_ORIGIN_REV_ID: 4f2bb29122df6979ad378227fb88e4632d3551f7
This commit is contained in:
parent
ecfe7f81d9
commit
4c3bcb882e
@ -13,11 +13,12 @@ extern crate json_value_merge;
|
||||
use json_value_merge::Merge;
|
||||
use metadata_resolve::MetadataResolveFlagsInternal;
|
||||
|
||||
#[test_each::path(glob = "crates/metadata-resolve/tests/examples/*/", name(segments = 2))]
|
||||
// given an old-metadata.json and a new-metadata.json, do they both result in the same resolved
|
||||
// metadata?
|
||||
// this may stop working if we start tagging resolved Metadata with the paths to the input items
|
||||
// in which case we'll need to look at removing those before comparing the output
|
||||
#[test_each::path(glob = "crates/metadata-resolve/tests/examples/*/", name(segments = 2))]
|
||||
#[allow(clippy::needless_pass_by_value)] // must receive a `PathBuf`
|
||||
fn test_matching_output_metadata(comparison_folder_path: PathBuf) -> anyhow::Result<()> {
|
||||
let root_test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("tests");
|
||||
|
||||
|
@ -1,20 +1,17 @@
|
||||
//! Tests that attempt to resolve different metadata files and assert that they parse successfully
|
||||
//! or fail in the expected way.
|
||||
|
||||
#![cfg(test)]
|
||||
use std::fs;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
||||
use serde_json::Value;
|
||||
use std::{
|
||||
fs::{self},
|
||||
path::Path,
|
||||
path::PathBuf,
|
||||
};
|
||||
extern crate json_value_merge;
|
||||
|
||||
use metadata_resolve::MetadataResolveFlagsInternal;
|
||||
|
||||
#[test_each::path(glob = "crates/metadata-resolve/tests/passing/*/", name(segments = 2))]
|
||||
#[allow(clippy::needless_pass_by_value)] // must receive a `PathBuf`
|
||||
fn test_passing_metadata(comparison_folder_path: PathBuf) -> anyhow::Result<()> {
|
||||
let mut passing_example = comparison_folder_path.clone();
|
||||
passing_example.push("example.json");
|
||||
let passing_example = comparison_folder_path.join("example.json");
|
||||
|
||||
let metadata_resolve_flags_internal = MetadataResolveFlagsInternal {
|
||||
enable_boolean_expression_types: true,
|
||||
@ -32,12 +29,10 @@ fn test_passing_metadata(comparison_folder_path: PathBuf) -> anyhow::Result<()>
|
||||
}
|
||||
|
||||
#[test_each::path(glob = "crates/metadata-resolve/tests/failing/*/", name(segments = 2))]
|
||||
#[allow(clippy::needless_pass_by_value)] // must receive a `PathBuf`
|
||||
fn test_failing_metadata(comparison_folder_path: PathBuf) -> anyhow::Result<()> {
|
||||
let mut failing_example = comparison_folder_path.clone();
|
||||
failing_example.push("example.json");
|
||||
|
||||
let mut failing_reason = comparison_folder_path.clone();
|
||||
failing_reason.push("expected_error.txt");
|
||||
let failing_example = comparison_folder_path.join("example.json");
|
||||
let failing_reason = comparison_folder_path.join("expected_error.txt");
|
||||
|
||||
let metadata_resolve_flags_internal = MetadataResolveFlagsInternal {
|
||||
enable_boolean_expression_types: true,
|
||||
|
@ -36,10 +36,10 @@ build-local:
|
||||
# linting run by CI
|
||||
ci-lint:
|
||||
just docker_with_source_only sh -c \
|
||||
"RUSTFLAGS='-D warnings' cargo clippy --no-deps"
|
||||
"RUSTFLAGS='-D warnings' cargo clippy --all-targets --no-deps"
|
||||
|
||||
fix:
|
||||
just docker_with_source_only sh -c "cargo clippy --no-deps --fix --allow-no-vcs; cargo fmt"
|
||||
just docker_with_source_only sh -c "cargo clippy --all-targets --no-deps --fix --allow-no-vcs; cargo fmt"
|
||||
|
||||
format:
|
||||
cargo fmt --check
|
||||
@ -47,7 +47,7 @@ format:
|
||||
alias fmt := format
|
||||
|
||||
fix-local:
|
||||
cargo clippy --no-deps --fix --allow-no-vcs
|
||||
cargo clippy --all-targets --no-deps --fix --allow-no-vcs
|
||||
cargo fmt
|
||||
just fix-format
|
||||
|
||||
@ -140,7 +140,7 @@ watch-local: start-docker-test-deps start-docker-run-deps
|
||||
|
||||
# check the code is fine
|
||||
lint-local:
|
||||
cargo clippy --no-deps
|
||||
cargo clippy --all-targets --no-deps
|
||||
|
||||
# ensure we don't have unused dependencies:
|
||||
machete:
|
||||
|
Loading…
Reference in New Issue
Block a user