Skip to content

Commit 85ba97d

Browse files
theduketheduke
authored and
theduke
committed
Clean up introspection tests
* Prefix test function names with 'introspection' * Use graphql_value! macro instead of manual construction
1 parent 9b021b2 commit 85ba97d

File tree

1 file changed

+38
-80
lines changed

1 file changed

+38
-80
lines changed

juniper/src/tests/introspection_tests.rs

+38-80
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use types::scalars::EmptyMutation;
77
use value::Value;
88

99
#[test]
10-
fn test_query_type_name() {
10+
fn test_introspection_query_type_name() {
1111
let doc = r#"
1212
query IntrospectionQueryTypeQuery {
1313
__schema {
@@ -22,30 +22,21 @@ fn test_query_type_name() {
2222
assert_eq!(
2323
::execute(doc, None, &schema, &Variables::new(), &database),
2424
Ok((
25-
Value::object(
26-
vec![(
27-
"__schema",
28-
Value::object(
29-
vec![(
30-
"queryType",
31-
Value::object(
32-
vec![("name", Value::scalar("Query"))].into_iter().collect(),
33-
),
34-
)]
35-
.into_iter()
36-
.collect(),
37-
),
38-
)]
39-
.into_iter()
40-
.collect()
41-
),
25+
graphql_value!({
26+
"__schema": {
27+
"queryType": {
28+
"name": "Query"
29+
}
30+
}
31+
32+
}),
4233
vec![]
4334
))
4435
);
4536
}
4637

4738
#[test]
48-
fn test_specific_type_name() {
39+
fn test_introspection_type_name() {
4940
let doc = r#"
5041
query IntrospectionQueryTypeQuery {
5142
__type(name: "Droid") {
@@ -58,21 +49,18 @@ fn test_specific_type_name() {
5849
assert_eq!(
5950
::execute(doc, None, &schema, &Variables::new(), &database),
6051
Ok((
61-
Value::object(
62-
vec![(
63-
"__type",
64-
Value::object(vec![("name", Value::scalar("Droid"))].into_iter().collect()),
65-
)]
66-
.into_iter()
67-
.collect()
68-
),
52+
graphql_value!({
53+
"__type": {
54+
"name": "Droid",
55+
},
56+
}),
6957
vec![]
7058
))
7159
);
7260
}
7361

7462
#[test]
75-
fn test_specific_object_type_name_and_kind() {
63+
fn test_introspection_specific_object_type_name_and_kind() {
7664
let doc = r#"
7765
query IntrospectionDroidKindQuery {
7866
__type(name: "Droid") {
@@ -87,28 +75,19 @@ fn test_specific_object_type_name_and_kind() {
8775
assert_eq!(
8876
::execute(doc, None, &schema, &Variables::new(), &database),
8977
Ok((
90-
Value::object(
91-
vec![(
92-
"__type",
93-
Value::object(
94-
vec![
95-
("name", Value::scalar("Droid")),
96-
("kind", Value::scalar("OBJECT")),
97-
]
98-
.into_iter()
99-
.collect(),
100-
),
101-
)]
102-
.into_iter()
103-
.collect()
104-
),
105-
vec![]
78+
graphql_value!({
79+
"__type": {
80+
"name": "Droid",
81+
"kind": "OBJECT",
82+
}
83+
}),
84+
vec![],
10685
))
10786
);
10887
}
10988

11089
#[test]
111-
fn test_specific_interface_type_name_and_kind() {
90+
fn test_introspection_specific_interface_type_name_and_kind() {
11291
let doc = r#"
11392
query IntrospectionDroidKindQuery {
11493
__type(name: "Character") {
@@ -123,28 +102,19 @@ fn test_specific_interface_type_name_and_kind() {
123102
assert_eq!(
124103
::execute(doc, None, &schema, &Variables::new(), &database),
125104
Ok((
126-
Value::object(
127-
vec![(
128-
"__type",
129-
Value::object(
130-
vec![
131-
("name", Value::scalar("Character")),
132-
("kind", Value::scalar("INTERFACE")),
133-
]
134-
.into_iter()
135-
.collect(),
136-
),
137-
)]
138-
.into_iter()
139-
.collect()
140-
),
105+
graphql_value!({
106+
"__type": {
107+
"name": "Character",
108+
"kind": "INTERFACE",
109+
}
110+
}),
141111
vec![]
142112
))
143113
);
144114
}
145115

146116
#[test]
147-
fn test_documentation() {
117+
fn test_introspection_documentation() {
148118
let doc = r#"
149119
query IntrospectionDroidDescriptionQuery {
150120
__type(name: "Droid") {
@@ -159,31 +129,19 @@ fn test_documentation() {
159129
assert_eq!(
160130
::execute(doc, None, &schema, &Variables::new(), &database),
161131
Ok((
162-
Value::object(
163-
vec![(
164-
"__type",
165-
Value::object(
166-
vec![
167-
("name", Value::scalar("Droid")),
168-
(
169-
"description",
170-
Value::scalar("A mechanical creature in the Star Wars universe."),
171-
),
172-
]
173-
.into_iter()
174-
.collect(),
175-
),
176-
)]
177-
.into_iter()
178-
.collect()
179-
),
132+
graphql_value!({
133+
"__type": {
134+
"name": "Droid",
135+
"description": "A mechanical creature in the Star Wars universe.",
136+
},
137+
}),
180138
vec![]
181139
))
182140
);
183141
}
184142

185143
#[test]
186-
fn test_possible_types() {
144+
fn test_introspection_possible_types() {
187145
let doc = r#"
188146
query IntrospectionDroidDescriptionQuery {
189147
__type(name: "Character") {

0 commit comments

Comments
 (0)