Skip to content

Commit f056c91

Browse files
committed
Clean up integration test setup + add impl_object tests
1 parent 4fe2e50 commit f056c91

File tree

4 files changed

+30
-13
lines changed

4 files changed

+30
-13
lines changed

integration_tests/juniper_tests/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ publish = false
55
edition = "2018"
66

77
[dev-dependencies]
8-
juniper = { version = "0.11.0", path = "../../juniper" }
8+
juniper = { path = "../../juniper" }
99
serde_json = { version = "1" }
1010
fnv = "1.0.3"
11-
indexmap = "1.0"

integration_tests/juniper_tests/src/codegen/derive_object.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ struct Obj {
1919
#[graphql(
2020
name = "renamedField",
2121
description = "descr",
22-
deprecation = "field descr"
22+
deprecation = "field deprecation"
2323
)]
2424
c: i32,
2525
}
@@ -75,7 +75,7 @@ struct Context;
7575
impl juniper::Context for Context {}
7676

7777
#[derive(GraphQLObject, Debug)]
78-
#[graphql(Context = "Context")]
78+
#[graphql(Context = Context)]
7979
struct WithCustomContext {
8080
a: bool,
8181
}
@@ -124,7 +124,7 @@ juniper::graphql_object!(Query: () |&self| {
124124
});
125125

126126
#[test]
127-
fn test_doc_comment() {
127+
fn test_doc_comment_simple() {
128128
let mut registry: juniper::Registry = juniper::Registry::new(FnvHashMap::default());
129129
let meta = DocComment::meta(&(), &mut registry);
130130
assert_eq!(meta.description(), Some(&"Object comment.".to_string()));

integration_tests/juniper_tests/src/codegen/impl_object.rs

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use super::util;
2-
use juniper::{EmptyMutation, Executor, GraphQLType};
2+
use juniper::{graphql_value, EmptyMutation, Executor, GraphQLObject, GraphQLType};
33

44
#[derive(GraphQLObject)]
55
struct SomeType {
@@ -8,15 +8,25 @@ struct SomeType {
88

99
#[derive(Default)]
1010
struct Context {
11-
version: Option<String>,
11+
flag1: bool,
1212
}
1313

14+
impl juniper::Context for Context {}
1415

1516
#[derive(Default)]
1617
struct TheQuery {
1718
b: bool,
1819
}
1920

21+
struct WithContext;
22+
23+
#[juniper::impl_object(Context=Context)]
24+
impl WithContext {
25+
fn ctx(ctx: &Context) -> bool {
26+
ctx.flag1
27+
}
28+
}
29+
2030
#[juniper::impl_object(
2131
scalar = juniper::DefaultScalarValue,
2232
name = "Query",
@@ -33,19 +43,19 @@ impl TheQuery {
3343
100
3444
}
3545

36-
fn with_executor(exec: &Executor<Context>) -> bool {
46+
fn with_executor(_exec: &Executor<Context>) -> bool {
3747
true
3848
}
3949

40-
fn with_executor_and_self(&self, exec: &Executor<Context>) -> bool {
50+
fn with_executor_and_self(&self, _exec: &Executor<Context>) -> bool {
4151
true
4252
}
4353

44-
fn with_context(exec: &Context) -> bool {
54+
fn with_context(_context: &Context) -> bool {
4555
true
4656
}
4757

48-
fn with_context_and_self(&self, exec: &Context) -> bool {
58+
fn with_context_and_self(&self, _context: &Context) -> bool {
4959
true
5060
}
5161

@@ -65,12 +75,16 @@ impl TheQuery {
6575
}
6676

6777
fn has_argument(arg1: bool) -> bool {
68-
true
78+
arg1
6979
}
7080

7181
fn has_object_return(&self) -> SomeType {
7282
SomeType { a: true }
7383
}
84+
85+
fn with_context_child(&self) -> WithContext {
86+
WithContext
87+
}
7488
}
7589

7690
#[derive(Default)]
@@ -155,6 +169,11 @@ fn impl_object_full_introspect() {
155169
"description": None,
156170
"args": [],
157171
},
172+
{
173+
"name": "withContextChild",
174+
"description": None,
175+
"args": [],
176+
},
158177
]
159178
})
160179
);

integration_tests/juniper_tests/src/codegen/util.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use fnv::FnvHashMap;
21
use juniper::{DefaultScalarValue, GraphQLType, RootNode, Value, Variables};
32
use std::default::Default;
43

0 commit comments

Comments
 (0)