Skip to content

Commit

Permalink
Flip if_exists test to check restore, not create
Browse files Browse the repository at this point in the history
  • Loading branch information
WillNilges committed Apr 6, 2024
1 parent 6204841 commit 2e2828d
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions dbbackup/tests/test_connectors/test_postgresql.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,15 +213,16 @@ def test_create_dump_drop(self, mock_dump_cmd):
self.connector.create_dump()
self.assertNotIn(" --clean", mock_dump_cmd.call_args[0][0])

def test_create_dump_if_exists(self, mock_dump_cmd):
def test_create_dump_if_exists(self, mock_dump_cmd, mock_restore_cmd):
dump = self.connector.create_dump()
# Without
self.connector.if_exists = False
self.connector.create_dump()
self.assertNotIn(" --if-exists", mock_dump_cmd.call_args[0][0])
self.connector.restore_dump(dump)
self.assertNotIn(" --if-exists", mock_restore_cmd.call_args[0][0])
# With
self.connector.if_exists = True
self.connector.create_dump()
self.assertIn(" --if-exists", mock_dump_cmd.call_args[0][0])
self.connector.restore_dump(dump)
self.assertIn(" --if-exists", mock_restore_cmd.call_args[0][0])

@patch(
"dbbackup.db.postgresql.PgDumpBinaryConnector.run_command",
Expand Down

0 comments on commit 2e2828d

Please sign in to comment.