Files
dvc/tests/unit/command/test_gc.py
T
15ada9a1c3 Implement --date to exp gc
1. Implement `--time` to `exp gc`
2. add a unit test for it.
3. Rename `--time` to `--date` and change the warning msg.
4. To get a better msg for `gc` and `exp gc`

Co-authored-by: Peter Rowlands (변기호) <[email protected]>
Co-authored-by: Dave Berenbaum <[email protected]>
2022-07-12 13:53:46 +02:00

55 lines
1.2 KiB
Python

import pytest
from dvc.cli import parse_args
from dvc.commands.gc import CmdGC
from dvc.exceptions import InvalidArgumentError
def test_(dvc, scm, mocker):
cli_args = parse_args(
[
"gc",
"--workspace",
"--all-tags",
"--all-branches",
"--all-commits",
"--all-experiments",
"--date",
"2022-06-30",
"--cloud",
"--remote",
"origin",
"--force",
"--jobs",
"3",
"--projects",
"project1",
"project2",
]
)
assert cli_args.func == CmdGC
cmd = cli_args.func(cli_args)
m = mocker.patch("dvc.repo.Repo.gc", return_value={})
assert cmd.run() == 0
m.assert_called_once_with(
workspace=True,
all_tags=True,
all_branches=True,
all_commits=True,
all_experiments=True,
commit_date="2022-06-30",
cloud=True,
remote="origin",
force=True,
jobs=3,
repos=["project1", "project2"],
)
cli_args = parse_args(["gc"])
cmd = cli_args.func(cli_args)
with pytest.raises(InvalidArgumentError):
cmd.run()