summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAndrew Godwin <andrew@aeracode.org>2014-11-15 17:37:13 +0100
committerAndrew Godwin <andrew@aeracode.org>2014-11-15 17:39:02 +0100
commitc5def493d0993d65bf7d96f0a204006cbeaa6178 (patch)
treef728adbd4dc8f06f3dc2c1197b928b82e865753c /tests
parentc1584e1df45a28cc374f634982065472dd23cc11 (diff)
Fixed #23835: Changed circular dependency in DFS to be less infinite
Diffstat (limited to 'tests')
-rw-r--r--tests/migrations/test_graph.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tests/migrations/test_graph.py b/tests/migrations/test_graph.py
index e70481a462..5b3f5b8467 100644
--- a/tests/migrations/test_graph.py
+++ b/tests/migrations/test_graph.py
@@ -188,3 +188,30 @@ class GraphTests(TestCase):
msg = "Migration app_a.0002 dependencies reference nonexistent child node ('app_a', '0002')"
with self.assertRaisesMessage(NodeNotFoundError, msg):
graph.add_dependency("app_a.0002", ("app_a", "0002"), ("app_a", "0001"))
+
+ def test_infinite_loop(self):
+ """
+ Tests a complex dependency graph:
+
+ app_a: 0001 <-
+ \
+ app_b: 0001 <- x 0002 <-
+ / \
+ app_c: 0001<- <------------- x 0002
+
+ And apply sqashing on app_c.
+ """
+ graph = MigrationGraph()
+
+ graph.add_node(("app_a", "0001"), None)
+ graph.add_node(("app_b", "0001"), None)
+ graph.add_node(("app_b", "0002"), None)
+ graph.add_node(("app_c", "0001_squashed_0002"), None)
+
+ graph.add_dependency("app_b.0001", ("app_b", "0001"), ("app_c", "0001_squashed_0002"))
+ graph.add_dependency("app_b.0002", ("app_b", "0002"), ("app_a", "0001"))
+ graph.add_dependency("app_b.0002", ("app_b", "0002"), ("app_b", "0001"))
+ graph.add_dependency("app_c.0001_squashed_0002", ("app_c", "0001_squashed_0002"), ("app_b", "0002"))
+
+ with self.assertRaises(CircularDependencyError):
+ graph.forwards_plan(("app_c", "0001_squashed_0002"))