fix: add postgres.dump_db() function

This commit is contained in:
Lance Edgar 2024-12-18 19:05:34 -06:00
parent c2e18d854c
commit 34459c008f
2 changed files with 41 additions and 0 deletions

View file

@ -122,3 +122,13 @@ class TestDropDb(TestCase):
mod.drop_db(c, 'foo')
db_exists.assert_called_once_with(c, 'foo')
c.sudo.assert_not_called()
class TestDumpDb(TestCase):
def test_basic(self):
c = MagicMock()
result = mod.dump_db(c, 'foo')
self.assertEqual(result, 'foo.sql.gz')
c.sudo.assert_called_once_with('pg_dump foo | gzip -c > /tmp/foo.sql.gz', user='postgres')
c.run.assert_called_with('rm /tmp/foo.sql.gz')