From d57d2c7d60fd5cfa43e83445675a87da9ce19d29 Mon Sep 17 00:00:00 2001 From: Dave Henderson Date: Wed, 14 Jun 2017 00:42:15 -0400 Subject: Enhancing indent function Signed-off-by: Dave Henderson --- test/integration/strings.bats | 30 ++++++++++++++++++++++++++++++ test/integration/typeconv_funcs.bats | 8 -------- 2 files changed, 30 insertions(+), 8 deletions(-) create mode 100644 test/integration/strings.bats (limited to 'test') diff --git a/test/integration/strings.bats b/test/integration/strings.bats new file mode 100644 index 00000000..9d16eb25 --- /dev/null +++ b/test/integration/strings.bats @@ -0,0 +1,30 @@ +#!/usr/bin/env bats + +load helper + +tmpdir=$(mktemp -u) + +function setup () { + mkdir -p $tmpdir +} + +function teardown () { + rm -rf $tmpdir || true +} + +@test "'strings.Indent'" { + gomplate -i '{{ strings.Indent " " "hello world" }} +{{ "hello\nmultiline\nworld" | indent 2 "-" }} +{{ "foo\nbar" | strings.Indent 2 }} + {{"hello\nworld" | strings.Indent 5 | strings.TrimSpace }} +' + [ "$status" -eq 0 ] + [[ "${output}" == " hello world +--hello +--multiline +--world + foo + bar + hello + world" ]] +} diff --git a/test/integration/typeconv_funcs.bats b/test/integration/typeconv_funcs.bats index 0b22f311..bb6f52bd 100644 --- a/test/integration/typeconv_funcs.bats +++ b/test/integration/typeconv_funcs.bats @@ -44,14 +44,6 @@ function teardown () { }' ]] } -@test "indent" { - gomplate -i '{{ indent " " "hello world" }}{{ "hello\nmultiline\nworld" | indent " " }}' - [ "$status" -eq 0 ] - [[ "${output}" == " hello world hello - multiline - world" ]] -} - @test "join" { gomplate -i '{{ $a := `[1, 2, 3]` | jsonArray }}{{ join $a "-" }}' [ "$status" -eq 0 ] -- cgit v1.2.3