Skip to content

Commit

Permalink
Add test case for exec label (#132)
Browse files Browse the repository at this point in the history
  • Loading branch information
m90 authored Jul 15, 2022
1 parent 3f10d0f commit 26c8ba9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
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.archive-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

0 comments on commit 26c8ba9

Please sign in to comment.