Skip to content

Commit

Permalink
Merge pull request #2 from cuchi/add-tests
Browse files Browse the repository at this point in the history
Add case for variables with whitespace
  • Loading branch information
cuchi authored Feb 8, 2020
2 parents 8fb5ea1 + 94cd457 commit b9280e9
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 6 deletions.
21 changes: 16 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,27 @@ jobs:
- name: '[test] many variables'
run: diff test/many-variables/result test/many-variables/expected

- name: '[run] many variables (messy whitespace)'
- name: '[run] many variables declared with messy whitespace'
uses: ./
with:
template: test/many-variables/template
output_file: test/many-variables/result
variables: |
foo=bar
baz=cux
foo=bar
baz=cux
- name: '[test] many variables (messy whitespace)'
run: diff test/many-variables/result test/many-variables/expected
- name: '[test] many variables declared with messy whitespace'
run: diff test/many-variables/result test/many-variables/expected

- name: '[run] many variables with messy whitespace'
uses: ./
with:
template: test/whitespace/template
output_file: test/whitespace/result
variables: |
foo=this variable has whitespace but it only takes one line
bar= \nthis\nvariable\nhas\nmany\n \nlines\n and trailing whitespace
- name: '[test] many variables with messy whitespace'
run: diff test/whitespace/result test/whitespace/expected
2 changes: 1 addition & 1 deletion entrypoint.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
params = [os.environ['INPUT_TEMPLATE']]

for variable in os.environ.get('INPUT_VARIABLES', '').split('\n'):
clean_variable = variable.strip()
clean_variable = bytes(variable.strip(), 'utf-8').decode('unicode_escape')
if clean_variable != '':
params.extend(['-D', clean_variable])

Expand Down
10 changes: 10 additions & 0 deletions test/whitespace/expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@

this variable has whitespace but it only takes one line

this
variable
has
many

lines
and trailing whitespace
3 changes: 3 additions & 0 deletions test/whitespace/template
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

{{ foo }}
{{ bar }}

0 comments on commit b9280e9

Please sign in to comment.