1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Refs #26709 -- Required a name for Indexes passed to AddIndex.

Thanks to Markush for discussions.
This commit is contained in:
Akshesh
2016-07-07 12:00:55 +05:30
committed by Tim Graham
parent f1af076fba
commit b1e7d19d4c
3 changed files with 14 additions and 5 deletions

View File

@@ -1385,7 +1385,13 @@ class OperationTests(OperationTestBase):
Test the AddIndex operation.
"""
project_state = self.set_up_test_model("test_adin")
index = models.Index(fields=["pink"])
msg = (
"Indexes passed to AddIndex operations require a name argument. "
"<Index: fields='pink'> doesn't have one."
)
with self.assertRaisesMessage(ValueError, msg):
migrations.AddIndex("Pony", models.Index(fields=["pink"]))
index = models.Index(fields=["pink"], name="test_adin_pony_pink_idx")
operation = migrations.AddIndex("Pony", index)
self.assertEqual(operation.describe(), "Create index on field(s) pink of model Pony")
new_state = project_state.clone()