Skip to content

Commit

Permalink
Added unittests for settings, render, and build. Fixed bug in render cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanrichholt committed Feb 6, 2019
1 parent dab7bf2 commit ba4fc10
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 3 deletions.
3 changes: 0 additions & 3 deletions jetstream/cli/subcommands/render.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
"""Render a template and print the results"""
import logging
import jetstream
from jetstream import settings
from jetstream.templates import context, render_template

log = logging.getLogger(__name__)
Expand All @@ -19,7 +17,6 @@ def main(args):
log.debug(f'{__name__} {args}')

c = context(
constants=settings['constants'].get(dict),
project=args.project,
command_args=args.kvargs
)
Expand Down
12 changes: 12 additions & 0 deletions test/templates/should_pass/retry.jst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- name: fails_once
retry: 1
stdout: /dev/null
cmd: |
if [ ! -f foo.txt ]; then
echo "File not found!"
touch foo.txt
exit 1
else
echo "File was found!"
fi

68 changes: 68 additions & 0 deletions test/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,71 @@ def test_tasks(self):

with redirect_stdout(StringIO()):
cli_main(args)

def test_render(self):
render_test = """
##//#/##/##
###//##/###//##
###//###//##//###
##///##///##///##
##///##///###//##
##///##///###//##
#/##/# ##///##///###//##
#/#/##/# ##///##///###//##
#/#/##/# ##///##///###//##
#/#/##/# ##///##///###//##
#/#/##/# ##///##///###//##
#/#/##/# ##///##///###//##
#/#/##/# ##///##///###//## *#/#/#(/#
#/#//##/////////##///##///###//## /#//#//#/(#
#/##////////////##///##///###//## ##/##//#//#
#///##############///##///###//## ##/##//#//#
#################///##///###//## ##/##//#//#
##///##///###//## ##/##//#//#
##///##///###//## ##/##//#//#
##///##///###//## ##/##//#//#
##///##///###//##########//##//#//#
##///##///###//##############//#//#
##///##///###//##/////////////##//#
##///##///###//################//##
##///##///###//##//////////////###
##///##///###//##
##///##///###//##
##///##///###//##
##///##///###//##
##///##///###//##
##///##///###//##
##///##///###//##
##///##///###//##
##///##///###//##
##///##///###//##
##///##///###//##
"""
with open('testwf.jst', 'w') as fp:
fp.write(render_test)

args = CMD_ARGS + [
'render',
'testwf.jst'
]

cli_main(args)

def test_build(self):
with open('testwf.jst', 'w') as fp:
fp.write('- cmd: true\n stdout: /dev/null\n')

args = CMD_ARGS + [
'build',
'testwf.jst'
]

cli_main(args)

def test_settings(self):
args = CMD_ARGS + [
'settings',
]

cli_main(args)

0 comments on commit ba4fc10

Please sign in to comment.