From 3bac0654d81a51157efd1dc30dfbeb5c71cc22cd Mon Sep 17 00:00:00 2001 From: Jon Bernard Date: Fri, 21 Sep 2018 13:43:03 -0400 Subject: Fix state tests --- tests/test_dotfile.py | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/tests/test_dotfile.py b/tests/test_dotfile.py index 9d04eed..fdb51da 100644 --- a/tests/test_dotfile.py +++ b/tests/test_dotfile.py @@ -24,31 +24,27 @@ def test_short_name(repo, name): assert dotfile.short_name(repo.homedir) == name -def test_state_error(repo): - dotfile = _dotfile(repo, '.vimrc') +def test_state(repo): + dotfile = _dotfile(repo, '.vimrc', 'vimrc') assert dotfile.state == 'error' - -def test_state_missing(repo): - dotfile = _dotfile(repo, '.vimrc') dotfile.target.ensure() - assert dotfile.state == 'missing' + dotfile.name.mksymlinkto(dotfile.target) + assert dotfile.state == 'ok' + dotfile.name.remove() + assert dotfile.state == 'missing' -def test_state_conflict(repo): - dotfile = _dotfile(repo, '.vimrc') - dotfile.target.ensure() dotfile.name.ensure() - assert dotfile.state == 'conflict' + assert dotfile.state == 'ok' + with open(dotfile.name, 'w') as f: + f.write('test content') + assert dotfile.state == 'conflict' -def test_state_ok(repo): - dotfile = _dotfile(repo, '.vimrc', 'vimrc') - dotfile.target.ensure() - dotfile.name.mksymlinkto(dotfile.target) + with open(dotfile.target, 'w') as f: + f.write('test content') assert dotfile.state == 'ok' - dotfile.name.remove() - assert dotfile.state == 'missing' @pytest.mark.parametrize('path', ['.foo', '.foo/bar/baz']) -- cgit v1.2.3