Skip to content

Commit

Permalink
Fix warnings in juniper unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron committed Dec 3, 2024
1 parent 5fed670 commit 5f39b37
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 40 deletions.
2 changes: 1 addition & 1 deletion juniper/src/parser/tests/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ impl Query {
}
}

fn scalar_meta<T>(name: &'static str) -> MetaType
fn scalar_meta<T>(name: &'static str) -> MetaType<'static>
where
T: FromInputValue<DefaultScalarValue> + ParseScalarValue<DefaultScalarValue>,
T::Error: IntoFieldError,
Expand Down
5 changes: 2 additions & 3 deletions juniper/src/validation/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ pub use self::{
};

#[cfg(test)]
pub use self::test_harness::{
expect_fails_fn, expect_fails_fn_with_schema, expect_fails_rule, expect_fails_rule_with_schema,
expect_passes_fn, expect_passes_fn_with_schema, expect_passes_rule,
pub(crate) use self::test_harness::{
expect_fails_fn, expect_fails_rule, expect_fails_rule_with_schema, expect_passes_rule,
expect_passes_rule_with_schema,
};
49 changes: 13 additions & 36 deletions juniper/src/validation/test_harness.rs
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,13 @@ where
}
}

pub fn validate<'a, Q, M, Sub, F, S>(r: Q, m: M, s: Sub, q: &'a str, visit_fn: F) -> Vec<RuleError>
pub(crate) fn validate<'a, Q, M, Sub, F, S>(
r: Q,
m: M,
s: Sub,
q: &'a str,
visit_fn: F,
) -> Vec<RuleError>
where
S: ScalarValue + 'a,
Q: GraphQLType<S, TypeInfo = ()>,
Expand Down Expand Up @@ -931,7 +937,7 @@ where
ctx.into_errors()
}

pub fn expect_passes_rule<'a, V, F, S>(factory: F, q: &'a str)
pub(crate) fn expect_passes_rule<'a, V, F, S>(factory: F, q: &'a str)
where
S: ScalarValue + 'a,
V: Visitor<'a, S> + 'a,
Expand All @@ -940,15 +946,7 @@ where
expect_passes_rule_with_schema(QueryRoot, MutationRoot, SubscriptionRoot, factory, q);
}

pub fn expect_passes_fn<'a, F, S>(visit_fn: F, q: &'a str)
where
S: ScalarValue + 'a,
F: FnOnce(&mut ValidatorContext<'a, S>, &'a Document<S>),
{
expect_passes_fn_with_schema(QueryRoot, MutationRoot, SubscriptionRoot, visit_fn, q);
}

pub fn expect_passes_rule_with_schema<'a, Q, M, Sub, V, F, S>(
pub(crate) fn expect_passes_rule_with_schema<'a, Q, M, Sub, V, F, S>(
r: Q,
m: M,
s: Sub,
Expand All @@ -973,28 +971,7 @@ pub fn expect_passes_rule_with_schema<'a, Q, M, Sub, V, F, S>(
}
}

pub fn expect_passes_fn_with_schema<'a, Q, M, Sub, F, S>(
r: Q,
m: M,
s: Sub,
visit_fn: F,
q: &'a str,
) where
S: ScalarValue + 'a,
Q: GraphQLType<S, TypeInfo = ()>,
M: GraphQLType<S, TypeInfo = ()>,
Sub: GraphQLType<S, TypeInfo = ()>,
F: FnOnce(&mut ValidatorContext<'a, S>, &'a Document<S>),
{
let errs = validate(r, m, s, q, visit_fn);

if !errs.is_empty() {
print_errors(&errs);
panic!("Expected `visit_fn` to pass, but errors found");
}
}

pub fn expect_fails_rule<'a, V, F, S>(factory: F, q: &'a str, expected_errors: &[RuleError])
pub(crate) fn expect_fails_rule<'a, V, F, S>(factory: F, q: &'a str, expected_errors: &[RuleError])
where
S: ScalarValue + 'a,
V: Visitor<'a, S> + 'a,
Expand All @@ -1003,15 +980,15 @@ where
expect_fails_rule_with_schema(QueryRoot, MutationRoot, factory, q, expected_errors);
}

pub fn expect_fails_fn<'a, F, S>(visit_fn: F, q: &'a str, expected_errors: &[RuleError])
pub(crate) fn expect_fails_fn<'a, F, S>(visit_fn: F, q: &'a str, expected_errors: &[RuleError])
where
S: ScalarValue + 'a,
F: FnOnce(&mut ValidatorContext<'a, S>, &'a Document<S>),
{
expect_fails_fn_with_schema(QueryRoot, MutationRoot, visit_fn, q, expected_errors);
}

pub fn expect_fails_rule_with_schema<'a, Q, M, V, F, S>(
pub(crate) fn expect_fails_rule_with_schema<'a, Q, M, V, F, S>(
r: Q,
m: M,
factory: F,
Expand Down Expand Up @@ -1048,7 +1025,7 @@ pub fn expect_fails_rule_with_schema<'a, Q, M, V, F, S>(
}
}

pub fn expect_fails_fn_with_schema<'a, Q, M, F, S>(
pub(crate) fn expect_fails_fn_with_schema<'a, Q, M, F, S>(
r: Q,
m: M,
visit_fn: F,
Expand Down

0 comments on commit 5f39b37

Please sign in to comment.