Files
myos/spec/support/bin/docker
T
Yann Autissier 234739e531 fix the compose call: it never worked outside --dry-run
Setting IFS to a newline to pass the environment also stopped the command
line from splitting, so '-f a -f b' went out as a single argument and the two
words 'docker compose' were looked up as one program name. Every real command
was broken; only --dry-run, which prints a string, looked right.

The variables are now exported in a subshell instead of going through env(1),
which keeps values with spaces intact and leaves the command line to normal
word splitting.

The tests only checked what --dry-run printed, which is why they missed it.
spec/unit/compose_spec.sh now asserts the argv that is actually executed, for
both the plugin and the standalone binary.
2026-09-03 20:11:37 +02:00

23 lines
839 B
Bash
Executable File

#!/bin/sh
# Mock docker for myos tests: logs every call, answers a few read-only queries deterministically.
if [ -n "${MYOS_DOCKER_LOG:-}" ]; then
printf 'docker %s\n' "$*" >> "$MYOS_DOCKER_LOG"
# the environment is recorded too, so a test can assert what was exported
env > "$(dirname "$MYOS_DOCKER_LOG")/env.log"
fi
case "$1 $2" in
"compose version") echo "${MOCK_COMPOSE_VERSION:-2.29.0}" ;;
"compose config") echo "# mock compose config" ;;
"compose ps") : ;;
"compose "*) : ;;
"info --format") echo "${MOCK_SWARM_STATE:-inactive}" ;;
"run --rm") case "$*" in *"uname -m"*) echo x86_64 ;; *"uname -s"*) echo Linux ;; *) : ;; esac ;;
"images -q") : ;;
"ps -q") : ;;
"network ls") : ;;
"volume ls") : ;;
"version --format") echo 29.0.0 ;;
*) : ;;
esac
exit 0