mirror of
https://github.com/Stone-Red-Code/dvc.git
synced 2026-12-06 07:18:28 +01:00
dvc cli: fixed error in 'dvc config --list' in non repo dir (#6587)
* dvc cli: fixed error in 'dvc config --list' in non repo dir Fixes #6496 * Issue 6496: Added test that covers the issue * dvc cli: fixes error in 'dvc config <name>' in non dvc repo dir Fixes the specified error. Did some refactoring based on previous commits. Also added a test case for setting config in non dvc repo dir. Fixes #6496 * Issue-6496: dvc config --<level> and dvc config --list --<level> will now throw config error if ran in non dvc repo with repo only level * Issue 6496: Segregated config levels into repo and system levels that helped in simplifying the logic to decide appropriate level at the time of cli operation.
This commit is contained in:
@@ -77,6 +77,12 @@ def test_config_set_local(tmp_dir, dvc):
|
||||
assert (tmp_dir / ".dvc" / "config.local").read_text() == "\n"
|
||||
|
||||
|
||||
def test_config_set_in_non_dvc_repo(tmp_dir, caplog):
|
||||
assert main(["config", "core.analytics", "true"]) != 0
|
||||
out = caplog.text
|
||||
assert "Not inside a DVC repo" in out
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"args, ret, msg",
|
||||
[
|
||||
@@ -128,6 +134,21 @@ def test_config_get(tmp_dir, dvc, capsys, caplog, args, ret, msg):
|
||||
assert msg in text
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"args, ret",
|
||||
[
|
||||
(["--local", "core.remote"], 251),
|
||||
(["--project", "core.remote"], 251),
|
||||
(["core.remote"], 0),
|
||||
],
|
||||
)
|
||||
def test_config_get_in_non_dvc_repo(tmp_dir, caplog, args, ret):
|
||||
assert main(["config"] + args) == ret
|
||||
if ret != 0:
|
||||
out = caplog.text
|
||||
assert "Not inside a DVC repo" in out
|
||||
|
||||
|
||||
def test_config_list(tmp_dir, dvc, capsys):
|
||||
(tmp_dir / ".dvc" / "config").write_text(
|
||||
textwrap.dedent(
|
||||
@@ -169,6 +190,21 @@ def test_config_list(tmp_dir, dvc, capsys):
|
||||
assert "core.remote=myremote" in out
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"args, ret",
|
||||
[
|
||||
(["--list", "--local"], 251),
|
||||
(["--list", "--project"], 251),
|
||||
(["--list"], 0),
|
||||
],
|
||||
)
|
||||
def test_config_list_in_non_dvc_repo(tmp_dir, caplog, args, ret):
|
||||
assert main(["config"] + args) == ret
|
||||
if ret != 0:
|
||||
out = caplog.text
|
||||
assert "Not inside a DVC repo" in out
|
||||
|
||||
|
||||
@pytest.mark.parametrize(
|
||||
"args", [["core.analytics"], ["core.analytics", "false"], ["--unset"]]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user