mirror of
https://github.com/bigchaindb/bigchaindb.git
synced 2024-10-13 13:34:05 +00:00
Handle case when db already exists
This commit is contained in:
parent
61c9268294
commit
35344d87fa
@ -64,7 +64,14 @@ def run_configure(args, skip_if_exists=False):
|
|||||||
def run_init(args):
|
def run_init(args):
|
||||||
"""Initialize the database"""
|
"""Initialize the database"""
|
||||||
bigchaindb.config_utils.file_config(args.config)
|
bigchaindb.config_utils.file_config(args.config)
|
||||||
db.init()
|
# TODO Provide mechanism to:
|
||||||
|
# 1. prompt the user to inquire whether they wish to drop the db
|
||||||
|
# 2. force the init, (e.g., via -f flag)
|
||||||
|
try:
|
||||||
|
db.init()
|
||||||
|
except DatabaseAlreadyExists:
|
||||||
|
print('The database already exists.')
|
||||||
|
print('If you wish to re-initialize it, first drop it.')
|
||||||
|
|
||||||
|
|
||||||
def run_drop(args):
|
def run_drop(args):
|
||||||
|
@ -53,3 +53,9 @@ def test_bigchain_show_config(capsys, mock_file_config):
|
|||||||
pprint(config)
|
pprint(config)
|
||||||
expected_outout_config, _ = capsys.readouterr()
|
expected_outout_config, _ = capsys.readouterr()
|
||||||
assert output_config == expected_outout_config
|
assert output_config == expected_outout_config
|
||||||
|
|
||||||
|
|
||||||
|
def test_bigchain_run_init_when_db_exists(mock_file_config, mock_db_init_with_existing_db):
|
||||||
|
from bigchaindb.commands.bigchain import run_init
|
||||||
|
args = Namespace(config=None)
|
||||||
|
run_init(args)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user