summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr ?ebek <petrsebe1@gmail.com>2017-02-06 11:09:01 +0100
committerPetr ?ebek <petrsebe1@gmail.com>2017-02-06 11:09:01 +0100
commit2bbf769937580fcf542d3115c31acd1223fc8e55 (patch)
tree760c9ddf02eaee9c3219ec97d175130cbbbdadd3
parent16726b172cfadcce17eccad5ba1afb824f545d5e (diff)
downloadyoyo-2bbf769937580fcf542d3115c31acd1223fc8e55.tar.gz
Add test for lock_migration_table
-rw-r--r--yoyo/tests/test_backends.py20
1 files changed, 18 insertions, 2 deletions
diff --git a/yoyo/tests/test_backends.py b/yoyo/tests/test_backends.py
index 8b8ff81..b9a70f3 100644
--- a/yoyo/tests/test_backends.py
+++ b/yoyo/tests/test_backends.py
@@ -1,6 +1,8 @@
import pytest
+from threading import Thread
+import time
-from yoyo import backends
+from yoyo import backends, read_migrations
from yoyo.tests import get_test_backends
from yoyo.tests import with_migrations
@@ -107,8 +109,22 @@ class TestTransactionHandling(object):
As far as I know this behavior is PostgreSQL specific. We can't run
this test in sqlite as it does not support CREATE DATABASE.
"""
- from yoyo import read_migrations
for backend in get_test_backends(exclude={'sqlite'}):
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']
+