summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2017-05-06 12:49:39 -0400
committerDave Henderson <dhenderson@gmail.com>2017-05-06 12:58:05 -0400
commitf358f185e00bf92bf2095b1eebcc4c950588488d (patch)
tree48f6def4ef5162c7d9b6da2f9e2fa1d0b58d78d8 /test
parent582a78b12aa119bf7dc46b6722b5423a456bb456 (diff)
Fixing bug with 'has' and 'datasource' around referencing sub-maps in nested maps
Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/integration/datasources_file.bats12
-rw-r--r--test/integration/typeconv_funcs.bats19
2 files changed, 25 insertions, 6 deletions
diff --git a/test/integration/datasources_file.bats b/test/integration/datasources_file.bats
index 1a3ad824..9e22a834 100644
--- a/test/integration/datasources_file.bats
+++ b/test/integration/datasources_file.bats
@@ -13,17 +13,17 @@ function teardown () {
}
@test "supports json datasource file" {
- echo '{"foo": "bar"}' > $tmpdir/config.json
- gomplate -d config=$tmpdir/config.json -i '{{(datasource "config").foo}}'
+ echo '{"foo": {"bar": "baz"}}' > $tmpdir/config.json
+ gomplate -d config=$tmpdir/config.json -i '{{(datasource "config").foo.bar}}'
[ "$status" -eq 0 ]
- [[ "${output}" == "bar" ]]
+ [[ "${output}" == "baz" ]]
}
@test "supports YAML datasource file" {
- echo 'foo: bar' > $tmpdir/config.yml
- gomplate -d config=$tmpdir/config.yml -i '{{(datasource "config").foo}}'
+ echo -e 'foo:\n bar: baz' > $tmpdir/config.yml
+ gomplate -d config=$tmpdir/config.yml -i '{{(datasource "config").foo.bar}}'
[ "$status" -eq 0 ]
- [[ "${output}" == "bar" ]]
+ [[ "${output}" == "baz" ]]
}
@test "ds alias" {
diff --git a/test/integration/typeconv_funcs.bats b/test/integration/typeconv_funcs.bats
new file mode 100644
index 00000000..9127915e
--- /dev/null
+++ b/test/integration/typeconv_funcs.bats
@@ -0,0 +1,19 @@
+#!/usr/bin/env bats
+
+load helper
+
+tmpdir=$(mktemp -u)
+
+function setup () {
+ mkdir -p $tmpdir
+}
+
+function teardown () {
+ rm -rf $tmpdir || true
+}
+
+@test "'has' can handle sub-maps in nested maps" {
+ gomplate -d config=$tmpdir/config.yml -i '{{ has ("foo:\n bar:\n baz: qux" | yaml).foo.bar "baz"}}'
+ [ "$status" -eq 0 ]
+ [[ "${output}" == "true" ]]
+}