-
Notifications
You must be signed in to change notification settings - Fork 28
/
schema_comparator_test.rb
50 lines (42 loc) 路 1.2 KB
/
schema_comparator_test.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
require "test_helper"
class GraphQL::SchemaComparatorTest < Minitest::Test
def setup
@old_schema_idl = <<~SCHEMA
schema {
query: Query
}
type Query {
a: String!
}
SCHEMA
@new_schema_idl = <<~SCHEMA
schema {
query: Query
}
type Query {
a: Int
b: Int!
}
SCHEMA
end
def test_compare_handles_idls
result = GraphQL::SchemaComparator.compare(@old_schema_idl, @new_schema_idl)
assert_equal [
"Field `Query.a` changed type from `String!` to `Int`",
"Field `b` was added to object type `Query`",
"Type `Int` was added",
], result.changes.map(&:message)
assert_equal true, result.breaking?
end
def test_compare_handles_schema_objects
old_schema = GraphQL::Schema.from_definition(@old_schema_idl)
new_schema = GraphQL::Schema.from_definition(@new_schema_idl)
result = GraphQL::SchemaComparator.compare(old_schema, new_schema)
assert_equal [
"Field `Query.a` changed type from `String!` to `Int`",
"Field `b` was added to object type `Query`",
"Type `Int` was added",
], result.changes.map(&:message)
assert_equal true, result.breaking?
end
end