Fix tests.

This commit is contained in:
Christoph Herzog 2019-11-15 21:44:08 +01:00
parent b634ad39eb
commit f6c0bc7b02
7 changed files with 15 additions and 8 deletions

View file

@ -42,7 +42,7 @@ enum OverrideDocEnum {
#[test]
fn test_derived_enum() {
// Ensure that rename works.
assert_eq!(<SomeEnum as GraphQLType>::name(&()), Some("Some"));
assert_eq!(<SomeEnum as GraphQLType<DefaultScalarValue>>::name(&()), Some("Some"));
// Ensure validity of meta info.
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());

View file

@ -62,7 +62,7 @@ impl<'a> ToInputValue for &'a Fake {
}
}
impl<'a> GraphQLType for &'a Fake {
impl<'a> GraphQLType<DefaultScalarValue> for &'a Fake {
type Context = ();
type TypeInfo = ();
@ -93,7 +93,7 @@ struct WithLifetime<'a> {
#[test]
fn test_derived_input_object() {
assert_eq!(<Input as GraphQLType>::name(&()), Some("MyInput"));
assert_eq!(<Input as GraphQLType<DefaultScalarValue>>::name(&()), Some("MyInput"));
// Validate meta info.
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());

View file

@ -170,7 +170,7 @@ fn test_doc_comment_override() {
#[test]
fn test_derived_object() {
assert_eq!(<Obj as GraphQLType>::name(&()), Some("MyObj"));
assert_eq!(<Obj as GraphQLType<DefaultScalarValue>>::name(&()), Some("MyObj"));
// Verify meta info.
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());

View file

@ -31,7 +31,7 @@ impl User2 {
#[test]
fn test_scalar_value_simple() {
assert_eq!(<UserId as GraphQLType>::name(&()), Some("UserId"));
assert_eq!(<UserId as GraphQLType<DefaultScalarValue>>::name(&()), Some("UserId"));
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());
let meta = UserId::meta(&(), &mut registry);
@ -49,7 +49,7 @@ fn test_scalar_value_simple() {
#[test]
fn test_scalar_value_custom() {
assert_eq!(<CustomUserId as GraphQLType>::name(&()), Some("MyUserId"));
assert_eq!(<CustomUserId as GraphQLType<DefaultScalarValue>>::name(&()), Some("MyUserId"));
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());
let meta = CustomUserId::meta(&(), &mut registry);

View file

@ -37,6 +37,13 @@ impl ScalarValue for MyScalarValue {
}
}
fn as_str(&self) -> Option<&str> {
match *self {
MyScalarValue::String(ref s) => Some(s.as_str()),
_ => None,
}
}
fn as_float(&self) -> Option<f64> {
match *self {
MyScalarValue::Int(ref i) => Some(*i as f64),

View file

@ -5,7 +5,7 @@ use crate::{
executor::{ExecutionResult, Executor, Registry},
schema::meta::MetaType,
types::base::{Arguments, GraphQLType},
value::{ScalarValue, Value},
value::{ScalarValue},
};
impl<S, T, CtxT> GraphQLType<S> for Box<T>

View file

@ -139,7 +139,7 @@ fn impl_scalar_struct(
info: &(),
selection: Option<&[#crate_name::Selection<S>]>,
executor: &#crate_name::Executor<Self::Context, S>,
) -> #crate_name::Value<S> {
) -> #crate_name::ExecutionResult<S> {
#crate_name::GraphQLType::resolve(&self.0, info, selection, executor)
}
}