-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more tests of actual schemas to cynic-parser (#829)
- Loading branch information
Showing
11 changed files
with
1,868 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
macro_rules! schema_tests { | ||
($name: ident, $path: literal) => { | ||
mod $name { | ||
use similar_asserts::assert_eq; | ||
|
||
#[allow(non_upper_case_globals)] | ||
const SCHEMA: &str = include_str!($path); | ||
|
||
#[test] | ||
fn snapshot() { | ||
let parsed = cynic_parser::parse_type_system_document(SCHEMA) | ||
.map_err(|error| error.to_report(SCHEMA)) | ||
.unwrap(); | ||
insta::assert_snapshot!(parsed.to_sdl()); | ||
} | ||
|
||
#[test] | ||
fn double_roundtrip() { | ||
let parsed = cynic_parser::parse_type_system_document(SCHEMA) | ||
.map_err(|error| error.to_report(SCHEMA)) | ||
.unwrap(); | ||
let sdl = parsed.to_sdl(); | ||
|
||
let reparsed = cynic_parser::parse_type_system_document(&sdl) | ||
.map_err(|error| error.to_report(&sdl)) | ||
.unwrap(); | ||
|
||
assert_eq!(sdl, reparsed.to_sdl()); | ||
} | ||
} | ||
}; | ||
} | ||
|
||
schema_tests!(github, "../../schemas/github.graphql"); | ||
|
||
schema_tests!(books, "../../schemas/books.graphql"); | ||
|
||
schema_tests!(graphql_jobs, "../../schemas/graphql.jobs.graphql"); | ||
|
||
schema_tests!(raindancer, "../../schemas/raindancer.graphql"); | ||
|
||
schema_tests!(simple, "../../schemas/simple.graphql"); | ||
|
||
schema_tests!(starwars, "../../schemas/starwars.schema.graphql"); | ||
|
||
schema_tests!(test_cases, "../../schemas/test_cases.graphql"); |
This file was deleted.
Oops, something went wrong.
43 changes: 43 additions & 0 deletions
43
cynic-parser/tests/snapshots/actual_schemas__books__snapshot.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
--- | ||
source: cynic-parser/tests/actual_schemas.rs | ||
expression: parsed.to_sdl() | ||
--- | ||
schema { | ||
query: QueryRoot | ||
mutation: MutationRoot | ||
subscription: SubscriptionRoot | ||
} | ||
|
||
directive @ifdef on FIELD | ||
|
||
type Book { | ||
id: String! | ||
name: String! | ||
author: String! | ||
} | ||
|
||
type BookChanged { | ||
mutationType: MutationType! | ||
id: ID! | ||
book: Book | ||
} | ||
|
||
type MutationRoot { | ||
createBook(name: String!, author: String!): ID! | ||
deleteBook(id: ID!): Boolean! | ||
} | ||
|
||
enum MutationType { | ||
CREATED | ||
DELETED | ||
} | ||
|
||
type QueryRoot { | ||
books: [Book!]! | ||
} | ||
|
||
type SubscriptionRoot { | ||
interval(n: Int! = 1): Int! | ||
books(mutationType: MutationType): BookChanged! | ||
} | ||
|
File renamed without changes.
Oops, something went wrong.