From 26c8ba971f9e2a19f18485ae75c2776b20c3ad1c Mon Sep 17 00:00:00 2001 From: Frederik Ring Date: Fri, 15 Jul 2022 09:34:01 +0200 Subject: [PATCH] Add test case for exec label (#132) --- README.md | 2 +- test/commands/docker-compose.yml | 14 ++++++++++++++ test/commands/run.sh | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 18c2bda..68d16c1 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/test/commands/docker-compose.yml b/test/commands/docker-compose.yml index fe0d57f..5568b45 100644 --- a/test/commands/docker-compose.yml +++ b/test/commands/docker-compose.yml @@ -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: diff --git a/test/commands/run.sh b/test/commands/run.sh index 4649a4f..70a928e 100644 --- a/test/commands/run.sh +++ b/test/commands/run.sh @@ -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