Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
nosarthur committed Feb 6, 2018
1 parent 7e38e10 commit 3715242
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ The supported commands are
* `gita add <repo-path>`: add repo path
* `gita rm <repo-name>`: remove repo
* `gita ls`: display the status of all repos
* `gita ls <repo-name>`: display the absolute path of the specified repo. One can then enter that directory using ``cd `gita ls <repo>` ``
* `gita ls <repo-name>`: display the absolute path of the specified repo

The repo paths are saved in `~/.gita_path`

Expand Down
13 changes: 11 additions & 2 deletions tests/test_main.py
Original file line number Diff line number Diff line change
@@ -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):
Expand All @@ -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/'])


Expand Down

0 comments on commit 3715242

Please sign in to comment.