Skip to content

Commit

Permalink
test: add unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
very-doge-wow committed Mar 17, 2024
1 parent 88ab069 commit 5209a81
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 4 additions & 1 deletion reader/chart_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,15 @@ def generate_values_doc(doc: dict, helm_chart_path: str) -> dict:
for index, line in enumerate(values_lines):
if stella in line:
# found a stella doc string
# get the indent
match = re.search(r'^(\s+).*$', line)
indent_num = match.group(0).count(' ')-1 if match else 0
doc_string = ""
i = index
# check if the next line still is a comment, if so add it to docstring
while values_lines[i + 1].lstrip().startswith("#"):
# remove first char (#) and add newline
calc = values_lines[i + 1].replace("#", "", 1) + "\n"
calc = values_lines[i + 1].replace(" ", "", indent_num).replace("#", "", 1) + "\n"
if calc[0] == " ":
calc = calc.replace(" ", "", 1)
doc_string += calc
Expand Down
6 changes: 1 addition & 5 deletions reader/chart_reader_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,7 @@ def test_generate_values_docs_nested():
result = chart_reader.generate_values_doc(doc, "test/values-nested-docs")
print(result)
assert_that(result["values"], contains_inanyorder(
{
'name': 'replicaCount',
'description': 'how many replicas to deploy\n',
'default': {'replicaCount': 1}, 'example': ''
}
{'name': 'image', 'description': 'which image to deploy\n', 'default': {'image': {'repository': 'nginx', 'pullPolicy': 'IfNotPresent', 'tag': ''}}, 'example': '\nimage:\n repository: very-doge-wow/stella\n pullPolicy: IfNotPresent\n'}, {'name': 'image.tag', 'description': 'Overrides the image tag whose default is the chart appVersion.\n', 'default': {'image': {'tag': ''}}, 'example': '\nimage:\n tag: "latest"\n'}, {'name': 'replicaCount', 'description': 'how many replicas to deploy\n', 'default': {'replicaCount': 1}, 'example': ''}
))


Expand Down

0 comments on commit 5209a81

Please sign in to comment.