Skip to content

Commit 58893fa

Browse files
committed
Make tests and Clippy happy
1 parent e05ada8 commit 58893fa

File tree

3 files changed

+39
-7
lines changed

3 files changed

+39
-7
lines changed

juniper/src/tests/introspection_tests.rs

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
use std::collections::HashSet;
22

3-
use pretty_assertions::assert_eq;
4-
53
use super::schema_introspection::*;
64
use crate::{
7-
ScalarValue as _, graphql,
5+
ScalarValue as _, Value, graphql,
86
introspection::IntrospectionFormat,
97
schema::model::RootNode,
108
tests::fixtures::starwars::schema::{Database, Query},
119
types::scalars::{EmptyMutation, EmptySubscription},
1210
};
11+
use pretty_assertions::assert_eq;
1312

1413
#[tokio::test]
1514
async fn test_introspection_query_type_name() {
15+
// language=GraphQL
1616
let doc = r#"
1717
query IntrospectionQueryTypeQuery {
1818
__schema {
@@ -46,6 +46,7 @@ async fn test_introspection_query_type_name() {
4646

4747
#[tokio::test]
4848
async fn test_introspection_type_name() {
49+
// language=GraphQL
4950
let doc = r#"
5051
query IntrospectionQueryTypeQuery {
5152
__type(name: "Droid") {
@@ -74,6 +75,7 @@ async fn test_introspection_type_name() {
7475

7576
#[tokio::test]
7677
async fn test_introspection_specific_object_type_name_and_kind() {
78+
// language=GraphQL
7779
let doc = r#"
7880
query IntrospectionDroidKindQuery {
7981
__type(name: "Droid") {
@@ -105,6 +107,7 @@ async fn test_introspection_specific_object_type_name_and_kind() {
105107

106108
#[tokio::test]
107109
async fn test_introspection_specific_interface_type_name_and_kind() {
110+
// language=GraphQL
108111
let doc = r#"
109112
query IntrospectionDroidKindQuery {
110113
__type(name: "Character") {
@@ -136,6 +139,7 @@ async fn test_introspection_specific_interface_type_name_and_kind() {
136139

137140
#[tokio::test]
138141
async fn test_introspection_documentation() {
142+
// language=GraphQL
139143
let doc = r#"
140144
query IntrospectionDroidDescriptionQuery {
141145
__type(name: "Droid") {
@@ -167,6 +171,7 @@ async fn test_introspection_documentation() {
167171

168172
#[tokio::test]
169173
async fn test_introspection_directives() {
174+
// language=GraphQL
170175
let q = r#"
171176
query IntrospectionQuery {
172177
__schema {
@@ -189,7 +194,7 @@ async fn test_introspection_directives() {
189194
.await
190195
.unwrap();
191196

192-
let expected = graphql_value!({
197+
let expected: Value = graphql_value!({
193198
"__schema": {
194199
"directives": [
195200
{
@@ -209,6 +214,12 @@ async fn test_introspection_directives() {
209214
"INLINE_FRAGMENT",
210215
],
211216
},
217+
{
218+
"name": "oneOf",
219+
"locations": [
220+
"INPUT_OBJECT",
221+
],
222+
},
212223
{
213224
"name": "skip",
214225
"locations": [
@@ -227,11 +238,15 @@ async fn test_introspection_directives() {
227238
},
228239
});
229240

230-
assert_eq!(result, (expected, vec![]));
241+
assert_eq!(
242+
serde_json::to_string_pretty(&result.0).unwrap(),
243+
serde_json::to_string_pretty(&expected).unwrap(),
244+
);
231245
}
232246

233247
#[tokio::test]
234248
async fn test_introspection_possible_types() {
249+
// language=GraphQL
235250
let doc = r#"
236251
query IntrospectionDroidDescriptionQuery {
237252
__type(name: "Character") {

juniper/src/tests/schema_introspection.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,15 @@ pub(crate) fn schema_introspection_result() -> Value {
15361536
}
15371537
]
15381538
},
1539+
{
1540+
"name": "oneOf",
1541+
"description": null,
1542+
"isRepeatable": false,
1543+
"locations": [
1544+
"INPUT_OBJECT"
1545+
],
1546+
"args": []
1547+
},
15391548
{
15401549
"name": "skip",
15411550
"description": null,
@@ -3014,6 +3023,14 @@ pub(crate) fn schema_introspection_result_without_descriptions() -> Value {
30143023
}
30153024
]
30163025
},
3026+
{
3027+
"name": "oneOf",
3028+
"isRepeatable": false,
3029+
"locations": [
3030+
"INPUT_OBJECT"
3031+
],
3032+
"args": []
3033+
},
30173034
{
30183035
"name": "skip",
30193036
"isRepeatable": false,

juniper_codegen/src/graphql_input_object/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -641,8 +641,8 @@ impl Definition {
641641
let arms = variants.iter().enumerate().map(|(n, v)| {
642642
let variant_ident = &v.ident;
643643

644-
let pre_none_pats = iter::repeat(&none_pat).take(n);
645-
let post_none_pats = iter::repeat(&none_pat).take(variants.len() - n - 1);
644+
let pre_none_pats = iter::repeat_n(&none_pat, n);
645+
let post_none_pats = iter::repeat_n(&none_pat, variants.len() - n - 1);
646646

647647
quote! {
648648
(#( #pre_none_pats, )* #some_pat, #( #post_none_pats, )*) => {

0 commit comments

Comments
 (0)