From fcb365bf112b31122cb265b7101a7b0d100730ec Mon Sep 17 00:00:00 2001 From: Jose Diaz-Gonzalez Date: Sat, 18 May 2024 22:54:31 -0400 Subject: [PATCH] chore: format shell --- tests/sigil.bash | 41 +++++++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/tests/sigil.bash b/tests/sigil.bash index 1b16790..bfa898f 100644 --- a/tests/sigil.bash +++ b/tests/sigil.bash @@ -17,7 +17,7 @@ T_posix_var_check() { } T_posix_var_check_unset() { - echo 'Hello, ${name:?}' | $SIGIL -p &> /dev/null + echo 'Hello, ${name:?}' | $SIGIL -p &>/dev/null [[ $? -ne 0 ]] } @@ -87,52 +87,53 @@ T_splitkv_joinkv() { } T_json() { - result=$(echo '{"one": "two"}' | $SIGIL -i '{{ stdin | json | tojson }}') - [[ "$result" == "{\"one\":\"two\"}" ]] + result=$(echo '{"one": "two"}' | $SIGIL -i '{{ stdin | json | tojson }}') + [[ "$result" == "{\"one\":\"two\"}" ]] } T_json_deep() { - result=$(echo '{"foo": {"one": "two"}}' | $SIGIL -i '{{ stdin | json | tojson }}') - [[ "$result" == '{"foo":{"one":"two"}}' ]] + result=$(echo '{"foo": {"one": "two"}}' | $SIGIL -i '{{ stdin | json | tojson }}') + [[ "$result" == '{"foo":{"one":"two"}}' ]] } T_yaml() { - yaml="$(echo -e "one: two\nthree:\n- four\n- five")" - result="$(echo -e "$yaml" | $SIGIL -i '{{ stdin | yaml | toyaml }}')" - [[ "$result" == "$yaml" ]] + yaml="$(echo -e "one: two\nthree:\n- four\n- five")" + result="$(echo -e "$yaml" | $SIGIL -i '{{ stdin | yaml | toyaml }}')" + [[ "$result" == "$yaml" ]] } T_shell() { result="$($SIGIL -i '{{ sh "date +%m-%d-%Y" }}')" - [[ "$result" == "$(date +%m-%d-%Y)" ]] + [[ "$result" == "$(date +%m-%d-%Y)" ]] } T_httpget() { result="$($SIGIL -i '{{ httpget "https://httpbin.org/get" | json | pointer "/url" }}')" - [[ "$result" == "https://httpbin.org/get" ]] + [[ "$result" == "https://httpbin.org/get" ]] } T_custom_delim() { result="$(SIGIL_DELIMS={{{,}}} $SIGIL -i '{{ hello {{{ $name }}} }}' name=packer)" - [[ "$result" == "{{ hello packer }}" ]] + [[ "$result" == "{{ hello packer }}" ]] } T_substr() { result="$($SIGIL -i '{{ "abcdefgh" | substr "1:4" }}')" - [[ "$result" == "bcd" ]] + [[ "$result" == "bcd" ]] } T_substr_single_index() { result="$($SIGIL -i '{{ "abcdefgh" | substr ":4" }}')" - [[ "$result" == "abcd" ]] + [[ "$result" == "abcd" ]] } T_yamltojson() { result="$(printf 'joe:\n age: 32\n color: red' | $SIGIL -i '{{ stdin | yaml | tojson }}')" - [[ "$result" == '{"joe":{"age":32,"color":"red"}}' ]] + [[ "$result" == '{"joe":{"age":32,"color":"red"}}' ]] } T_yamltojsondeep() { - result="$( $SIGIL -i '{{ stdin | yaml | tojson }}' <= `30`].name | reverse(@)" | join ","}}')" - [[ "$result" == 'joe,jim' ]] + [[ "$result" == 'joe,jim' ]] } T_base64enc() { result="$(echo 'happybirthday' | $SIGIL -i '{{ stdin | base64enc }}')" - [[ "$result" == "aGFwcHliaXJ0aGRheQo=" ]] + [[ "$result" == "aGFwcHliaXJ0aGRheQo=" ]] } T_base64dec() { result="$(echo 'aGFwcHliaXJ0aGRheQo=' | $SIGIL -i '{{ stdin | base64dec }}')" - [[ "$result" == "happybirthday" ]] + [[ "$result" == "happybirthday" ]] }