コード例 #1
0
def test_output_config_yml():
    current = os.getcwd()
    config.generate_sample()  # 検証用の雛形を作成する

    current_dir = os.path.dirname(os.path.abspath(__file__))
    path_expected_file = os.path.join(current_dir, "expected", "config.yml")
    path_actual_file = ".circleci/config.yml"

    generate.output_config_yml("testproject", "testman")
    assert os.path.exists(path_actual_file)

    # 答えが変わった場合は、想定結果を置き換える)
    # import shutil
    # src = path_actual_file
    # dest = path_expected_file
    # shutil.copyfile(src, dest)

    actual_file = None
    expected_file = None

    with open(path_actual_file, "r") as f:
        actual_file = f.read()

    with open(path_expected_file, "r") as f:
        expected_file = f.read()

    # difflibを活用したかったが、エラーが綺麗に出力できなかったので自作でdiffする
    # import difflib

    actual_file = actual_file.splitlines()
    expected_file = expected_file.splitlines()

    for i in range(max(len(actual_file), len(expected_file))):
        assert actual_file[i] == expected_file[i]
コード例 #2
0
def test_validate():
    current = os.getcwd()
    config.generate_sample()  # 検証用の雛形を作成する

    result = runner.invoke(main.app, ["validate"])
    assert result.exit_code == 0

    # 禁止文字の確認
    os.mkdir("dockerfm/base/:")
    result = runner.invoke(main.app, ["validate"])
    assert result.exit_code != 0
    assert "Exists validation error" in result.stdout
    os.rmdir("dockerfm/base/:")

    # 禁止文字の確認
    os.mkdir("dockerfm/base/_")
    result = runner.invoke(main.app, ["validate"])
    assert result.exit_code != 0
    assert "Exists validation error" in result.stdout
    os.rmdir("dockerfm/base/_")

    # dockerfm.tomlの確認
    with open("dockerfm.toml", "w") as f:
        f.write("aaaa")

    result = runner.invoke(main.app, ["validate"])
    assert result.exit_code != 0
コード例 #3
0
ファイル: test_show.py プロジェクト: sasano8/dockerfm
def test_get_compose_files():
    current = os.getcwd()
    config.generate_sample()  # 検証用の雛形を作成する

    files = list(show.get_compose_files())
    files = sorted(files)

    assert files[0] == os.path.join(current, "dockerfm/base/dockercompose.yml")
    assert files[1] == os.path.join(current,
                                    "dockerfm/compose/dockercompose.yml")
コード例 #4
0
ファイル: test_show.py プロジェクト: sasano8/dockerfm
def test_dockerfile():
    current = os.getcwd()
    config.generate_sample()  # 検証用の雛形を作成する

    result = runner.invoke(main.app, ["show", "dockerfile"])
    items = result.stdout.splitlines()
    items = sorted(items)
    assert items[0] == "alpine"
    assert items[1] == "alpine1"
    assert items[2] == "alpine2"
コード例 #5
0
ファイル: test_show.py プロジェクト: sasano8/dockerfm
def test_compose():
    current = os.getcwd()
    config.generate_sample()  # 検証用の雛形を作成する

    result = runner.invoke(main.app, ["show", "compose"])
    items = result.stdout.splitlines()
    items = sorted(items)

    assert items[0] == "base"
    assert items[1] == "compose"
コード例 #6
0
def test_ci():
    current = os.getcwd()

    result = runner.invoke(main.app, ["ci"])
    assert result.exit_code != 0

    config.generate_sample()  # 検証用の雛形を作成する

    result = runner.invoke(main.app, ["ci"])
    assert result.exit_code == 0
コード例 #7
0
ファイル: test_show.py プロジェクト: sasano8/dockerfm
def test_get_dockerfilereadme_files():
    current = os.getcwd()
    config.generate_sample()  # 検証用の雛形を作成する

    files = list(show.get_dockerfilereadme_files())
    files = sorted(files)

    assert files[0] == os.path.join(current, "dockerfm/base/alpine/README.md")
    assert files[1] == os.path.join(current,
                                    "dockerfm/compose/alpine1/README.md")
    assert files[2] == os.path.join(current,
                                    "dockerfm/compose/alpine2/README.md")
コード例 #8
0
def test_list():
    current = os.getcwd()
    config.generate_sample()

    result = runner.invoke(main.app, ["config", "list"])
    items = result.stdout.splitlines()
    items = sorted(items)

    assert items[0] == "dockerfm_dir = ./dockerfm/"
    assert items[1] == "project = sample"
    assert items[2] == "user = yourname"

    assert len(items) == 3