Skip to content

Commit

Permalink
PR-hairyhenderson#119 : Add integration test for --input-dir
Browse files Browse the repository at this point in the history
  • Loading branch information
rhuss committed Apr 28, 2017
1 parent 0813040 commit aebfe7b
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions test/integration/input-dir.bats
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
#!/usr/bin/env bats

load helper

tmpdir=$(mktemp -u)

function setup () {
mkdir -p $tmpdir
mkdir -p $tmpdir/in/inner
echo -n "{{ (datasource \"config\").one }}" > $tmpdir/in/eins.txt
echo -n "{{ (datasource \"config\").two }}" > $tmpdir/in/inner/deux.txt

cat <<"EOT" > $tmpdir/config.yml
one: eins
two: deux
EOT
}

function teardown () {
# rm -rf $tmpdir
echo
}

@test "takes --input-dir and produces proper output files" {
rm -rf $tmpdir/out || true
gomplate --input-dir $tmpdir/in --output-dir $tmpdir/out -d config=$tmpdir/config.yml
[ "$status" -eq 0 ]
[[ "$(ls $tmpdir/out | wc -l)" == 2 ]]
[[ "$(ls $tmpdir/out/inner | wc -l)" == 1 ]]
[[ "$(cat $tmpdir/out/eins.txt)" == "eins" ]]
[[ "$(cat $tmpdir/out/inner/deux.txt)" == "deux" ]]
}

@test "test . as default --output-dir param" {
rm -rf $tmpdir/out_dot || true
mkdir -p $tmpdir/out_dot
g=$(pwd)/bin/gomplate
cd $tmpdir/out_dot
run $g --input-dir $tmpdir/in -d config=$tmpdir/config.yml
[ "$?" -eq 0 ]
[[ "$(ls | wc -l)" == 2 ]]
[[ "$(ls inner | wc -l)" == 1 ]]
[[ "$(cat eins.txt)" == "eins" ]]
[[ "$(cat inner/deux.txt)" == "deux" ]]
}

@test "errors given --output-dir but no --input-dir" {
gomplate --output-dir "."
[ "$status" -eq 1 ]
[[ "${output}" == "--input-dir must be set when --output-dir is set" ]]
}

@test "errors given both --input-dir and --in" {
gomplate --input-dir "." --in "param"
[ "$status" -eq 1 ]
[[ "${output}" == "--input-dir can not be used together with --in or --file" ]]
}

@test "errors given both --input-dir and --file" {
gomplate --input-dir "." --file input.txt
[ "$status" -eq 1 ]
[[ "${output}" == "--input-dir can not be used together with --in or --file" ]]
}

@test "errors given both --output-dir and --out" {
gomplate --input-dir "." --output-dir /tmp --out out
[ "$status" -eq 1 ]
[[ "${output}" == "--out can not be used together with --output-dir" ]]
}

0 comments on commit aebfe7b

Please sign in to comment.