Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test case for exec label #132

Merged
merged 1 commit into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1115,7 +1115,7 @@ services:
labels:
- docker-volume-backup.exec-pre=/bin/sh -c 'mysqldump -psecret --all-databases > /tmp/dumps/dump.sql'
volumes:
- app_data:/tmp/dumps
- data:/tmp/dumps
backup:
image: offen/docker-volume-backup:v2
environment:
Expand Down
14 changes: 14 additions & 0 deletions test/commands/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,20 @@ services:
volumes:
- 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:
image: offen/docker-volume-backup:${TEST_VERSION:-canary}
deploy:
Expand Down
5 changes: 5 additions & 0 deletions test/commands/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ if [ ! -f ./backup/data/dump.sql ]; then
fi
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
fail "File created in post command was present in backup."
fi
Expand Down