mirror of
https://github.com/lobaro/restic-backup-docker.git
synced 2026-11-21 17:02:39 +00:00
test: check the msmtp config copy at real container startup
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
bc3dfcd950
commit
140b29ef5a
2 files changed
+32
-4
No files matched your search
+4
-4
@@ -133,13 +133,13 @@ if require_feature msmtp "PR #84"; then
|
|||||||
assert_contains "$sendmail_target" "msmtp" \
|
assert_contains "$sendmail_target" "msmtp" \
|
||||||
"sendmail is provided by msmtp"
|
"sendmail is provided by msmtp"
|
||||||
|
|
||||||
start_container msmtp-config
|
# The config has to be in place when the container starts, entry.sh copies
|
||||||
if wait_for_start; then
|
# it. Re-running entry.sh in a live container would start a second crond.
|
||||||
write_file /config/msmtprc 'defaults
|
start_container_with_file msmtp-config /config/msmtprc 'defaults
|
||||||
account default
|
account default
|
||||||
host localhost
|
host localhost
|
||||||
'
|
'
|
||||||
in_container /entry.sh true >/dev/null 2>&1
|
if wait_for_start; then
|
||||||
if in_container test -f /etc/msmtprc; then
|
if in_container test -f /etc/msmtprc; then
|
||||||
pass "msmtp config from /config is copied to /etc/msmtprc"
|
pass "msmtp config from /config is copied to /etc/msmtprc"
|
||||||
mode="$(in_container stat -c '%a' /etc/msmtprc 2>&1 | tr -d '\r')"
|
mode="$(in_container stat -c '%a' /etc/msmtprc 2>&1 | tr -d '\r')"
|
||||||
|
|||||||
+28
@@ -128,6 +128,34 @@ start_container() {
|
|||||||
"$IMAGE" >/dev/null
|
"$IMAGE" >/dev/null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# start_container_with_file <name suffix> <path in container> <content> [extra docker run args...]
|
||||||
|
# Like start_container, but the file exists before entry.sh runs, so tests can
|
||||||
|
# cover what the entrypoint does with it at real container startup. The file is
|
||||||
|
# placed with `docker create` + `docker cp`, no bind mount.
|
||||||
|
start_container_with_file() {
|
||||||
|
local suffix="$1" path="$2" content="$3"
|
||||||
|
shift 3
|
||||||
|
local seed seed_src
|
||||||
|
seed="$(mktemp -d)"
|
||||||
|
printf '%s' "$content" > "${seed}/$(basename "$path")"
|
||||||
|
CONTAINER="rbd-test-${suffix}-$$"
|
||||||
|
docker rm -f "$CONTAINER" >/dev/null 2>&1 || true
|
||||||
|
docker create --name "$CONTAINER" \
|
||||||
|
-e RESTIC_PASSWORD=testpassword \
|
||||||
|
-e RESTIC_TAG=testtag \
|
||||||
|
-e "BACKUP_CRON=0 0 31 2 *" \
|
||||||
|
"$@" \
|
||||||
|
"$IMAGE" >/dev/null
|
||||||
|
if command -v cygpath >/dev/null 2>&1; then
|
||||||
|
seed_src="$(cygpath -w "$seed")"
|
||||||
|
else
|
||||||
|
seed_src="$seed"
|
||||||
|
fi
|
||||||
|
docker cp "${seed_src}/." "${CONTAINER}:$(dirname "$path")"
|
||||||
|
rm -rf "$seed"
|
||||||
|
docker start "$CONTAINER" >/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
stop_container() {
|
stop_container() {
|
||||||
[ -n "$CONTAINER" ] || return 0
|
[ -n "$CONTAINER" ] || return 0
|
||||||
docker rm -f "$CONTAINER" >/dev/null 2>&1 || true
|
docker rm -f "$CONTAINER" >/dev/null 2>&1 || true
|
||||||
|
|||||||
Reference in new issue
Block a user