Skip to content

Commit

Permalink
relocate snapshots dir
Browse files Browse the repository at this point in the history
  • Loading branch information
kattouf committed Jul 17, 2024
1 parent 0d8fc60 commit 72ceb1f
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions Tests/assert.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
#!/usr/bin/env bash
#
# Determine if the script is sourced or executed
if [[ "${BASH_SOURCE[0]}" != "${0}" ]]; then
# Script is being sourced
SNAPSHOTS_DIR="$(cd "$(dirname "${BASH_SOURCE[1]}")" && pwd)"
else
# Script is being executed
SNAPSHOTS_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
fi

# takes a name for snapshot file and string to compare to reference.
# If the snapshot file does not exist, it will be created.
# If the snapshot file does exist, the string will be compared to the snapshot.
Expand All @@ -6,8 +17,8 @@
assert_snapshot() {
local snapshot_name="$1"
local snapshot_value="$2"
local snapshot_file="snapshots/$snapshot_name.snapshot"
mkdir -p snapshots
local snapshot_file="$SNAPSHOTS_DIR/snapshots/$snapshot_name.snapshot"
mkdir -p "$SNAPSHOTS_DIR"

if [ "$SNAPSHOT_RECORD" = "true" ]; then
echo "Recording snapshot $snapshot_name" >&2
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 72ceb1f

Please sign in to comment.