mirror of
https://github.com/postgrespro/pg_probackup.git
synced 2024-12-01 09:51:43 +02:00
42 lines
1.2 KiB
Python
42 lines
1.2 KiB
Python
import unittest
|
|
import os
|
|
from os import path
|
|
import six
|
|
from .pb_lib import dir_files, ProbackupTest
|
|
|
|
|
|
class InitTest(ProbackupTest, unittest.TestCase):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
super(InitTest, self).__init__(*args, **kwargs)
|
|
|
|
def test_success_1(self):
|
|
"""Success normal init"""
|
|
node = self.make_bnode(base_dir="tmp_dirs/init/success_1")
|
|
self.assertEqual(self.init_pb(node), six.b(""))
|
|
self.assertEqual(
|
|
dir_files(self.backup_dir(node)),
|
|
['backups', 'pg_probackup.conf', 'wal']
|
|
)
|
|
|
|
def test_already_exist_2(self):
|
|
"""Failure with backup catalog already existed"""
|
|
node = self.make_bnode(base_dir="tmp_dirs/init/already_exist_2")
|
|
self.init_pb(node)
|
|
self.assertEqual(
|
|
self.init_pb(node),
|
|
six.b("ERROR: backup catalog already exist and it's not empty\n")
|
|
)
|
|
|
|
def test_abs_path_3(self):
|
|
"""failure with backup catalog should be given as absolute path"""
|
|
node = self.make_bnode(base_dir="tmp_dirs/init/abs_path_3")
|
|
self.assertEqual(
|
|
self.run_pb(["init", "-B", path.relpath("%s/backup" % node.base_dir, self.dir_path)]),
|
|
six.b("ERROR: -B, --backup-path must be an absolute path\n")
|
|
)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
unittest.main()
|