11#! /usr/bin/env bash
2+ # shellcheck disable=SC2155
23
34function set_up() {
45 export BASHUNIT_SIMPLE_OUTPUT=false
@@ -10,7 +11,6 @@ function test_successful_assert_match_snapshot() {
1011}
1112
1213function test_creates_a_snapshot() {
13- # shellcheck disable=SC2155
1414 local snapshot_path=" $( temp_dir) /assert_snapshot_test_sh.test_creates_a_snapshot.snapshot"
1515 local expected=$(( _ASSERTIONS_SNAPSHOT + 1 ))
1616
@@ -34,19 +34,16 @@ function test_unsuccessful_assert_match_snapshot() {
3434 Expected to match the snapshot" ) "
3535 fi
3636
37- local actual
38- actual=" $( assert_match_snapshot " Expected snapshot" ) "
37+ local actual=" $( assert_match_snapshot " Expected snapshot" ) "
3938
4039 assert_equals " $expected " " $actual "
4140}
4241
4342function test_successful_assert_match_snapshot_ignore_colors() {
44- local colored
45- colored=$( printf ' \e[31mHello\e[0m World!' )
43+ local colored=$( printf ' \e[31mHello\e[0m World!' )
4644 assert_empty " $( assert_match_snapshot_ignore_colors " $colored " ) "
4745}
4846
49- # shellcheck disable=SC2155
5047function test_creates_a_snapshot_ignore_colors() {
5148 local snapshot_path=" $( temp_dir) /assert_snapshot_test_sh.test_creates_a_snapshot_ignore_colors.snapshot"
5249 local expected=$(( _ASSERTIONS_SNAPSHOT + 1 ))
@@ -72,10 +69,8 @@ function test_unsuccessful_assert_match_snapshot_ignore_colors() {
7269 Expected to match the snapshot" ) "
7370 fi
7471
75- local actual
76- local colored
77- colored=$( printf ' \e[31mExpected snapshot\e[0m' )
78- actual=" $( assert_match_snapshot_ignore_colors " $colored " ) "
72+ local colored=$( printf ' \e[31mExpected snapshot\e[0m' )
73+ local actual=" $( assert_match_snapshot_ignore_colors " $colored " ) "
7974
8075 assert_equals " $expected " " $actual "
8176}
@@ -85,28 +80,20 @@ function test_assert_match_snapshot_with_placeholder() {
8580 skip " perl not available" && return
8681 fi
8782
88- local temp_dir
89- temp_dir=$( mktemp -d)
90- local snapshot_path=" $temp_dir /assert_snapshot_test_sh.test_assert_match_snapshot_with_placeholder.snapshot"
83+ local snapshot_path=" $( temp_dir) /assert_snapshot_test_sh.test_assert_match_snapshot_with_placeholder.snapshot"
9184 echo ' Run at ::ignore::' > " $snapshot_path "
9285
9386 assert_empty " $( assert_match_snapshot " Run at $( date -u ' +%F %T UTC' ) " " $snapshot_path " ) "
94-
95- rm -rf " $temp_dir "
9687}
9788
9889function test_assert_match_snapshot_with_custom_placeholder() {
9990 if ! dependencies::has_perl; then
10091 skip " perl not available" && return
10192 fi
10293
103- local temp_dir
104- temp_dir=$( mktemp -d)
105- local snapshot_path=" $temp_dir /assert_snapshot_test_sh.test_assert_match_snapshot_with_custom_placeholder.snapshot"
94+ local snapshot_path=" $( temp_dir) /assert_snapshot_test_sh.test_assert_match_snapshot_with_custom_placeholder.snapshot"
10695 echo ' Value __ANY__' > " $snapshot_path "
10796
10897 export BASHUNIT_SNAPSHOT_PLACEHOLDER=' __ANY__'
10998 assert_empty " $( assert_match_snapshot " Value 42" " $snapshot_path " ) "
110-
111- rm -rf " $temp_dir "
11299}
0 commit comments