aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test_repository.py
blob: 098704bd0287b98a79a7ac1bbb5e8ed2bf620aac (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from dotfiles.dotfile import Dotfile
from dotfiles.repository import Repository


def test_list(tmpdir):

    repo = tmpdir.ensure("Dotfiles", dir=1)
    name = tmpdir.join(".vimrc")
    target = repo.ensure("vimrc")

    dotfile = Dotfile(name, target)
    repository = Repository(repo, tmpdir)

    # manual discovery
    repository.dotfiles = [dotfile, dotfile, dotfile]

    expected_list = (".vimrc -> Dotfiles/vimrc (unknown)\n"
                     ".vimrc -> Dotfiles/vimrc (unknown)\n"
                     ".vimrc -> Dotfiles/vimrc (unknown)")

    assert expected_list == str(repository)


def test_discovery(tmpdir):

    repo = tmpdir.ensure("Dotfiles", dir=1)

    tmpdir.join('.bashrc').mksymlinkto(repo.ensure('bashrc'))
    tmpdir.join('.inputrc').mksymlinkto(repo.ensure('inputrc'))
    tmpdir.join('.vimrc').mksymlinkto(repo.ensure('vimrc'))

    repository = Repository(repo, tmpdir)

    expected_list = (".bashrc -> Dotfiles/bashrc (unknown)\n"
                     ".inputrc -> Dotfiles/inputrc (unknown)\n"
                     ".vimrc -> Dotfiles/vimrc (unknown)")

    assert expected_list == str(repository)