Skip to content

Commit c89e795

Browse files
committed
test(cli): Basic sync tests
1 parent 6810eac commit c89e795

File tree

1 file changed

+39
-7
lines changed

1 file changed

+39
-7
lines changed

tests/test_cli.py

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,46 @@
1-
import pytest
1+
import pathlib
22

3+
import yaml
34
from click.testing import CliRunner
45

6+
from libvcs.sync.git import GitSync
57
from vcspull.cli import cli
68

79

8-
@pytest.mark.skip(reason="todo")
9-
def test_command_line(self):
10+
def test_sync_cli_non_existent(tmp_path: pathlib.Path) -> None:
1011
runner = CliRunner()
11-
result = runner.invoke(cli, ["sync", "hi"])
12-
assert result.exit_code == 0
13-
assert "Debug mode is on" in result.output
14-
assert "Syncing" in result.output
12+
with runner.isolated_filesystem(temp_dir=tmp_path):
13+
result = runner.invoke(cli, ["sync", "hi"])
14+
assert result.exit_code == 0
15+
assert "" in result.output
16+
17+
18+
def test_sync(
19+
home_path: pathlib.Path,
20+
config_path: pathlib.Path,
21+
tmp_path: pathlib.Path,
22+
git_repo: GitSync,
23+
) -> None:
24+
runner = CliRunner()
25+
with runner.isolated_filesystem(temp_dir=tmp_path):
26+
config = {
27+
"~/github_projects/": {
28+
"my_git_repo": {
29+
"url": f"git+file://{git_repo.dir}",
30+
"remotes": {"test_remote": f"git+file://{git_repo.dir}"},
31+
},
32+
"broken_repo": {
33+
"url": f"git+file://{git_repo.dir}",
34+
"remotes": {"test_remote": "git+file://non-existent-remote"},
35+
},
36+
}
37+
}
38+
yaml_config = config_path / ".vcspull.yaml"
39+
yaml_config_data = yaml.dump(config, default_flow_style=False)
40+
yaml_config.write_text(yaml_config_data, encoding="utf-8")
41+
42+
# CLI can sync
43+
result = runner.invoke(cli, ["sync", "my_git_repo"])
44+
assert result.exit_code == 0
45+
output = "".join(list(result.output))
46+
assert "my_git_repo" in output

0 commit comments

Comments
 (0)