Add test case for exec label (#132)

This commit is contained in:
Frederik Ring 2022-07-15 09:34:01 +02:00 committed by GitHub
parent 3f10d0f817
commit 26c8ba971f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 1 deletions

View File

@ -1115,7 +1115,7 @@ services:
labels: labels:
- docker-volume-backup.archive-pre=/bin/sh -c 'mysqldump -psecret --all-databases > /tmp/dumps/dump.sql' - docker-volume-backup.archive-pre=/bin/sh -c 'mysqldump -psecret --all-databases > /tmp/dumps/dump.sql'
volumes: volumes:
- app_data:/tmp/dumps - data:/tmp/dumps
backup: backup:
image: offen/docker-volume-backup:v2 image: offen/docker-volume-backup:v2
environment: environment:

View File

@ -17,6 +17,20 @@ services:
volumes: volumes:
- app_data:/tmp/volume - app_data:/tmp/volume
other_database:
image: mariadb:10.7
deploy:
restart_policy:
condition: on-failure
environment:
MARIADB_ROOT_PASSWORD: test
MARIADB_DATABASE: backup
labels:
- docker-volume-backup.archive-pre=touch /tmp/volume/not-relevant.txt
- docker-volume-backup.exec-label=not-relevant
volumes:
- app_data:/tmp/volume
backup: backup:
image: offen/docker-volume-backup:${TEST_VERSION:-canary} image: offen/docker-volume-backup:${TEST_VERSION:-canary}
deploy: deploy:

View File

@ -18,6 +18,11 @@ if [ ! -f ./backup/data/dump.sql ]; then
fi fi
pass "Found expected file." pass "Found expected file."
if [ -f ./backup/data/not-relevant.txt ]; then
fail "Command ran for container with other label."
fi
pass "Command did not run for container with other label."
if [ -f ./backup/data/post.txt ]; then if [ -f ./backup/data/post.txt ]; then
fail "File created in post command was present in backup." fail "File created in post command was present in backup."
fi fi