Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions commodore/git.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,10 +161,10 @@ def stage_all(repo):
# and a_blob as after.
before = c.b_blob.data_stream.read().decode('utf-8').split('\n')
after = c.a_blob.data_stream.read().decode('utf-8').split('\n')
diff = difflib.unified_diff(before, after, lineterm='',
fromfile=c.b_path, tofile=c.a_path)
diff = [_colorize_diff(line) for line in diff]
difftext.append('\n'.join(diff).strip())
diff_lines = difflib.unified_diff(before, after, lineterm='',
fromfile=c.b_path, tofile=c.a_path)
diff_lines = [_colorize_diff(line) for line in diff_lines]
difftext.append('\n'.join(diff_lines).strip())

return '\n'.join(difftext), changed

Expand Down
14 changes: 14 additions & 0 deletions tests/test_git.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""
Unit-tests for git
"""

Comment thread
srueg marked this conversation as resolved.
from commodore import git
from pathlib import Path


def test_reconstruct_api_response(tmp_path: Path):
repo_path = tmp_path / 'test-repo'
repo_path.mkdir()
repo = git.create_repository(repo_path)
output = git.stage_all(repo)
assert output != ""
Comment thread
srueg marked this conversation as resolved.
18 changes: 8 additions & 10 deletions tests/test_target.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import click
import pytest
import commodore.cluster as cluster
from commodore import cluster


cluster_obj = {
Expand All @@ -22,16 +22,14 @@
def test_render_target():
target = cluster._full_target(cluster_obj, components, catalog)
facts = cluster_obj['facts']
all_classes = [f"defaults.{cn}" for cn in components] + [
'global.common',
f"global.{facts['distribution']}",
f"global.{facts['cloud']}",
f"{cluster_obj['tenant']}.{cluster_obj['id']}"]
Comment thread
srueg marked this conversation as resolved.
assert target != ""
all_classes = ([f"defaults.{cn}" for cn in components] +
['global.common',
f"global.{facts['distribution']}",
f"global.{facts['cloud']}",
f"{cluster_obj['tenant']}.{cluster_obj['id']}",
])
assert len(target['classes']) == len(
all_classes), "rendered target includes different amount of classes"
# Test order of included classes
assert len(target['classes']) == len(all_classes), \
"rendered target includes different amount of classes"
for i in range(len(all_classes)):
assert target['classes'][i] == all_classes[i]
assert target['parameters']['target_name'] == 'cluster'
Expand Down