diff --git a/README.md b/README.md index 26fb005..faebfdd 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ The supported commands are * `gita add `: add repo path * `gita rm `: remove repo * `gita ls`: display the status of all repos -* `gita ls `: display the absolute path of the specified repo. One can then enter that directory using ``cd `gita ls ` `` +* `gita ls `: display the absolute path of the specified repo The repo paths are saved in `~/.gita_path` diff --git a/tests/test_main.py b/tests/test_main.py index 68d300e..1869e22 100644 --- a/tests/test_main.py +++ b/tests/test_main.py @@ -1,10 +1,18 @@ from gita import __main__ +from gita import ls -def test_ls(): +def test_ls(monkeypatch, capfd): + monkeypatch.setattr(__main__, 'update_repos', + lambda: {'repo1':'/a/', 'repo2':'/b/'}) + monkeypatch.setattr(ls, 'describe', lambda x: x) __main__.main(['ls']) -# __main__.main(['ls', 'a-repo']) + out, err = capfd.readouterr() + assert out == "{'repo1': '/a/', 'repo2': '/b/'}\n" + __main__.main(['ls', 'repo1']) + out, err = capfd.readouterr() + assert out == '/a/\n' def test_rm(monkeypatch): @@ -15,6 +23,7 @@ def test_rm(monkeypatch): def test_add(): + # this won't write to disk because the repo is not valid __main__.main(['add', '/home/some/repo/'])