Skip to content

Commit 9ecffbd

Browse files
committed
find_breaking_changes: Add new tests to improve coverage
Replicates graphql/graphql-js@2fae6e7
1 parent c6c295f commit 9ecffbd

File tree

2 files changed

+48
-9
lines changed

2 files changed

+48
-9
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ a query language for APIs created by Facebook.
1313
[![Code Style](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/ambv/black)
1414

1515
The current version 1.0.4 of GraphQL-core-next is up-to-date with GraphQL.js version
16-
14.3.0. All parts of the API are covered by an extensive test suite of currently 1778
16+
14.3.0. All parts of the API are covered by an extensive test suite of currently 1779
1717
unit tests.
1818

1919

tests/utilities/test_find_breaking_changes.py

Lines changed: 47 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,21 +36,35 @@ def should_detect_if_a_type_was_removed_or_not():
3636
def should_detect_if_a_type_changed_its_type():
3737
old_schema = build_schema(
3838
"""
39-
interface Type1
39+
scalar TypeWasScalarBecomesEnum
40+
interface TypeWasInterfaceBecomesUnion
41+
type TypeWasObjectBecomesInputObject
4042
"""
4143
)
4244

4345
new_schema = build_schema(
4446
"""
45-
union Type1
47+
enum TypeWasScalarBecomesEnum
48+
union TypeWasInterfaceBecomesUnion
49+
input TypeWasObjectBecomesInputObject
4650
"""
4751
)
4852

4953
assert find_breaking_changes(old_schema, new_schema) == [
5054
(
5155
BreakingChangeType.TYPE_CHANGED_KIND,
52-
"Type1 changed from an Interface type to a Union type.",
53-
)
56+
"TypeWasScalarBecomesEnum changed from a Scalar type to an Enum type.",
57+
),
58+
(
59+
BreakingChangeType.TYPE_CHANGED_KIND,
60+
"TypeWasInterfaceBecomesUnion changed"
61+
" from an Interface type to a Union type.",
62+
),
63+
(
64+
BreakingChangeType.TYPE_CHANGED_KIND,
65+
"TypeWasObjectBecomesInputObject changed"
66+
" from an Object type to an Input type.",
67+
),
5468
]
5569

5670
def should_detect_if_a_field_on_type_was_deleted_or_changed_type():
@@ -564,6 +578,27 @@ def should_detect_interfaces_removed_from_types():
564578
)
565579
]
566580

581+
def should_ignore_changes_in_order_of_interfaces():
582+
old_schema = build_schema(
583+
"""
584+
interface FirstInterface
585+
interface SecondInterface
586+
587+
type Type1 implements FirstInterface & SecondInterface
588+
"""
589+
)
590+
591+
new_schema = build_schema(
592+
"""
593+
interface FirstInterface
594+
interface SecondInterface
595+
596+
type Type1 implements SecondInterface & FirstInterface
597+
"""
598+
)
599+
600+
assert find_breaking_changes(old_schema, new_schema) == []
601+
567602
def should_detect_all_breaking_changes():
568603
old_schema = build_schema(
569604
"""
@@ -839,22 +874,26 @@ def should_detect_if_a_value_was_added_to_an_enum_type():
839874
def should_detect_interfaces_added_to_types():
840875
old_schema = build_schema(
841876
"""
842-
type Type1
877+
interface OldInterface
878+
interface NewInterface
879+
880+
type Type1 implements OldInterface
843881
"""
844882
)
845883

846884
new_schema = build_schema(
847885
"""
848-
interface Interface1
886+
interface OldInterface
887+
interface NewInterface
849888
850-
type Type1 implements Interface1
889+
type Type1 implements OldInterface & NewInterface
851890
"""
852891
)
853892

854893
assert find_dangerous_changes(old_schema, new_schema) == [
855894
(
856895
DangerousChangeType.INTERFACE_ADDED_TO_OBJECT,
857-
"Interface1 added to interfaces implemented by Type1.",
896+
"NewInterface added to interfaces implemented by Type1.",
858897
)
859898
]
860899

0 commit comments

Comments
 (0)