Skip to content

Commit 03fd38d

Browse files
committed
fix: assert_snapshot_test with placeholder
1 parent fb9237b commit 03fd38d

3 files changed

Lines changed: 10 additions & 6 deletions

tests/unit/assert_snapshot_test.sh

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,22 +84,28 @@ function test_assert_match_snapshot_with_placeholder() {
8484
skip "not supported on alpine" && return
8585
fi
8686

87-
# shellcheck disable=SC2155
88-
local snapshot_path="$(temp_dir)/assert_snapshot_test_sh.test_assert_match_snapshot_with_placeholder.snapshot"
87+
local temp_dir
88+
temp_dir=$(mktemp -d)
89+
local snapshot_path="$temp_dir/assert_snapshot_test_sh.test_assert_match_snapshot_with_placeholder.snapshot"
8990
echo 'Run at ::ignore::' > "$snapshot_path"
9091

9192
assert_empty "$(assert_match_snapshot "Run at $(date)" "$snapshot_path")"
93+
94+
rm -rf "$temp_dir"
9295
}
9396

9497
function test_assert_match_snapshot_with_custom_placeholder() {
9598
if check_os::is_alpine; then
9699
skip "not supported on alpine" && return
97100
fi
98101

99-
# shellcheck disable=SC2155
100-
local snapshot_path="$(temp_dir)/assert_snapshot_test_sh.test_assert_match_snapshot_with_custom_placeholder.snapshot"
102+
local temp_dir
103+
temp_dir=$(mktemp -d)
104+
local snapshot_path="$temp_dir/assert_snapshot_test_sh.test_assert_match_snapshot_with_custom_placeholder.snapshot"
101105
echo 'Value __ANY__' > "$snapshot_path"
102106

103107
export BASHUNIT_SNAPSHOT_PLACEHOLDER='__ANY__'
104108
assert_empty "$(assert_match_snapshot "Value 42" "$snapshot_path")"
109+
110+
rm -rf "$temp_dir"
105111
}

tests/unit/snapshots/assert_snapshot_test_sh.test_assert_match_snapshot_with_custom_placeholder.snapshot

Lines changed: 0 additions & 1 deletion
This file was deleted.

tests/unit/snapshots/assert_snapshot_test_sh.test_assert_match_snapshot_with_placeholder.snapshot

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)