Skip to content

Commit

Permalink
Fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
theduke committed Nov 15, 2019
1 parent b634ad3 commit f6c0bc7
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 8 deletions.
2 changes: 1 addition & 1 deletion integration_tests/juniper_tests/src/codegen/derive_enum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ();

Expand Down Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
7 changes: 7 additions & 0 deletions integration_tests/juniper_tests/src/custom_scalar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion juniper/src/types/pointers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion juniper_codegen/src/derive_scalar_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit f6c0bc7

Please sign in to comment.