Skip to content

Commit 3c813ff

Browse files
test: make optional tool warning deterministic
1 parent 6edab64 commit 3c813ff

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

dream-server/tests/bats-tests/preflight-phase.bats

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ MOCK
221221
touch "$SCRIPT_DIR/docker-compose.base.yml"
222222
mkdir -p "$BATS_TEST_TMPDIR/bin"
223223

224-
# Create curl, jq, and sed wrappers but NOT rsync, then use an isolated PATH
224+
# Create curl and jq, then shadow command -v rsync so the warning path is deterministic
225225
cat > "$BATS_TEST_TMPDIR/bin/curl" << 'MOCK'
226226
#!/bin/bash
227227
echo "curl 8.0.0"
@@ -232,20 +232,17 @@ MOCK
232232
echo "jq-1.7"
233233
MOCK
234234
chmod +x "$BATS_TEST_TMPDIR/bin/jq"
235-
cat > "$BATS_TEST_TMPDIR/bin/sed" << 'MOCK'
236-
#!/bin/bash
237-
/usr/bin/sed "$@"
238-
MOCK
239-
chmod +x "$BATS_TEST_TMPDIR/bin/sed"
235+
export PATH="$BATS_TEST_TMPDIR/bin:$PATH"
240236

241-
run /usr/bin/env PATH="'"$BATS_TEST_TMPDIR/bin"'" /usr/bin/bash -c '
237+
run bash -c '
242238
export SCRIPT_DIR="'"$SCRIPT_DIR"'"
243239
export INSTALL_DIR="'"$INSTALL_DIR"'"
244240
export LOG_FILE="'"$LOG_FILE"'"
245241
export INTERACTIVE=false
246242
export DRY_RUN=false
247243
export PKG_MANAGER="apt"
248244
export VERSION="2.3.0"
245+
export PATH="'"$BATS_TEST_TMPDIR/bin:$PATH"'"
249246
250247
log() { :; }
251248
warn() { echo "WARN: $1"; }
@@ -256,6 +253,12 @@ MOCK
256253
show_phase() { :; }
257254
show_stranger_boot() { :; }
258255
dream_progress() { :; }
256+
command() {
257+
if [[ "$1" == "-v" && "$2" == "rsync" ]]; then
258+
return 1
259+
fi
260+
builtin command "$@"
261+
}
259262
260263
source "'"$BATS_TEST_DIRNAME/../../installers/phases/01-preflight.sh"'"
261264
'

0 commit comments

Comments
 (0)