summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr ?ebek <petrsebe1@gmail.com>2017-02-06 11:15:49 +0100
committerPetr ?ebek <petrsebe1@gmail.com>2017-02-06 11:15:49 +0100
commit24ba3b04ee98b4846c1ecf4539117d7fda4d8450 (patch)
tree132069c4aecb50b9f59d4d88606e7ee1bc437e11
parent16726b172cfadcce17eccad5ba1afb824f545d5e (diff)
downloadyoyo-24ba3b04ee98b4846c1ecf4539117d7fda4d8450.tar.gz
Add test for lock_migration_table
-rw-r--r--yoyo/tests/test_backends.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/yoyo/tests/test_backends.py b/yoyo/tests/test_backends.py
index 8b8ff81..d567689 100644
--- a/yoyo/tests/test_backends.py
+++ b/yoyo/tests/test_backends.py
@@ -1,6 +1,8 @@
import pytest
+import time
+from threading import Thread
-from yoyo import backends
+from yoyo import backends, read_migrations
from yoyo.tests import get_test_backends
from yoyo.tests import with_migrations
@@ -112,3 +114,17 @@ class TestTransactionHandling(object):
migrations = read_migrations(tmpdir)
backend.apply_migrations(migrations)
backend.rollback_migrations(migrations)
+
+
+ @with_migrations(a="""
+ steps = [
+ step("SELECT pg_sleep(1)"),
+ ]
+ """)
+ def test_lock_migration_table(self, tmpdir):
+ backend = get_test_backends(only={'postgresql'})[0]
+ migrations = read_migrations(tmpdir)
+ Thread(target = backend.apply_migrations, args = (migrations,)).start()
+ # give a chance to start, but wake up in the middle of applying
+ time.sleep(0.1)
+ assert backend.get_applied_migration_ids() == ['a']