@@ -16,54 +16,29 @@ import (
1616 "github.com/pkg/errors"
1717)
1818
19- func TestGitHubSchema (t * testing.T ) {
20- schema := filepath .Join (".." , ".." , "example" , "github" , "schema.graphql" )
21- root , err := loader .LoadSchema (schema )
22- if err != nil {
23- t .Fatalf ("%+v" , err )
24- }
25-
26- root2 , err := LoadSchema (schema )
27- if err != nil {
28- t .Fatal (err )
29- }
30-
31- if diff := cmp .Diff (root2 , root , cmpopts .IgnoreUnexported (introspection.Schema {})); diff != "" {
32- t .Fatalf ("-want, +got\n %s" , diff )
19+ func TestExampleSchema (t * testing.T ) {
20+ cases := []string {
21+ "github" ,
22+ "shopify" ,
23+ "starwars" ,
3324 }
34- }
35-
36- func TestStarwarsSchema (t * testing.T ) {
37- schema := filepath .Join (".." , ".." , "example" , "starwars" , "schema.graphql" )
38- root , err := loader .LoadSchema (schema )
39- if err != nil {
40- t .Fatal (err )
41- }
42-
43- root2 , err := LoadSchema (schema )
44- if err != nil {
45- t .Fatal (err )
46- }
47-
48- if diff := cmp .Diff (root2 , root , cmpopts .IgnoreUnexported (introspection.Schema {})); diff != "" {
49- t .Fatalf ("-want, +got\n %s" , diff )
50- }
51- }
52-
53- func TestShopifySchema (t * testing.T ) {
54- schema := filepath .Join (".." , ".." , "example" , "shopify" , "schema.graphql" )
55- root , err := loader .LoadSchema (schema )
56- if err != nil {
57- t .Fatal (err )
58- }
59-
60- root2 , err := LoadSchema (schema )
61- if err != nil {
62- t .Fatal (err )
63- }
64-
65- if diff := cmp .Diff (root2 , root , cmpopts .IgnoreUnexported (introspection.Schema {})); diff != "" {
66- t .Fatalf ("-want, +got\n %s" , diff )
25+ for _ , example := range cases {
26+ t .Run ("example " + example , func (t * testing.T ) {
27+ schema := filepath .Join (".." , ".." , "example" , example , "schema.graphql" )
28+ root , err := loader .LoadSchema (schema )
29+ if err != nil {
30+ t .Fatalf ("%+v" , err )
31+ }
32+
33+ root2 , err := LoadSchema (schema )
34+ if err != nil {
35+ t .Fatal (err )
36+ }
37+
38+ if diff := cmp .Diff (root2 , root , cmpopts .IgnoreUnexported (introspection.Schema {})); diff != "" {
39+ t .Fatalf ("-want, +got\n %s" , diff )
40+ }
41+ })
6742 }
6843}
6944
0 commit comments