Test Setup Failed
Push — master ( 2faa8c...0a634f )
by Jace
01:14
created

tmp()   A

Complexity

Conditions 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
c 1
b 0
f 0
dl 0
loc 7
rs 9.4285
1
# pylint: disable=redefined-outer-name,unused-variable,expression-not-assigned,singleton-comparison
2
3
import os
4
from pathlib import Path
5
from contextlib import suppress
6
7
import pytest
8
from expecter import expect
9
10
from click.testing import CliRunner
11
12
from envdiff.cli import main
13
14
15
@pytest.fixture
16
def runner():
17
    return CliRunner()
18
19
20
@pytest.yield_fixture
21
def tmp(path=Path("tmp", "int", "cli").resolve()):
22
    cwd = Path.cwd()
23
    path.mkdir(parents=True, exist_ok=True)
24
    os.chdir(path)
25
    yield path
26
    os.chdir(cwd)
27
28
29
def describe_cli():
30
31
    def describe_init():
32
33
        def when_config_missing(runner, tmp):
34
            path = tmp.joinpath("env-diff.yml")
35
            with suppress(FileNotFoundError):
36
                path.unlink()
37
38
            result = runner.invoke(main, ['--init'])
39
40
            expect(result.output) == (
41
                "Generated config file: {}\n".format(path) +
42
                "Edit this file to match your application\n"
43
            )
44
            expect(result.exit_code) == 0
45
46
    def describe_run():
47
48
        def when_config_missing(runner, tmp):
49
            path = tmp.joinpath("env-diff.yml")
50
            with suppress(FileNotFoundError):
51
                path.unlink()
52
53
            result = runner.invoke(main, [])
54
55
            expect(result.output) == \
56
                "No config file found, generate one with '--init'\n"
57
            expect(result.exit_code) == 1
58