Skip to content

Commit

Permalink
Adds test to catch optional config being required
Browse files Browse the repository at this point in the history
  • Loading branch information
consideRatio committed Nov 30, 2019
1 parent 7330a6d commit 234d870
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import shutil
import tempfile
from distutils.dir_util import copy_tree

Expand Down Expand Up @@ -38,3 +39,18 @@ def git_repo(monkeypatch):
r.index.commit("initial commit")

yield r

@pytest.fixture(scope="function")
def git_repo_bare_minimum(monkeypatch, git_repo):
"""
This fixture modifies the default git_repo fixture to use another the
chartpress_bare_minimum.yaml as chartpress.yaml and removes the image
directory.
"""
r = git_repo
shutil.move("chartpress_bare_minimum.yaml", "chartpress.yaml")
shutil.rmtree("image")
r.git.add(all=True)
r.index.commit("bare minimum commit")

yield r
2 changes: 2 additions & 0 deletions tests/test_helm_chart/chartpress_bare_minimum.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
charts:
- name: testchart
14 changes: 14 additions & 0 deletions tests/test_repo_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,20 @@ def test_chartpress_paths_configuration(git_repo, capfd):
assert f"Updating testchart/values.yaml: image: testchart/testimage:{tag}" in out


def test_chartpress_run_bare_minimum(git_repo_bare_minimum, capfd):
"""
Ensures that chartpress will run with a minimal configuration of only
providing a single chart name. This can catch errors that assumes we need to
have a images key in the chartpress.yaml configuration for example.
"""
r = git_repo_bare_minimum
sha = r.heads.master.commit.hexsha[:7]
tag = f"0.0.1-002.{sha}"

out = _capture_output([], capfd)
assert f"Updating testchart/Chart.yaml: version: {tag}" in out


def _capture_output(args, capfd):
"""
Calls chartpress given provided arguments and captures the output during the
Expand Down

0 comments on commit 234d870

Please sign in to comment.