Skip to content

Commit dfca0ab

Browse files
authored
Add unit test for track progress (#659)
* Add unit test for track progress * add end_test * change test and fix init-progress * Make the test go green * Update ghe-backup-config
1 parent a9d1345 commit dfca0ab

File tree

2 files changed

+20
-9
lines changed

2 files changed

+20
-9
lines changed

share/github-backup-utils/ghe-backup-config

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -661,17 +661,13 @@ prompt_for_confirmation(){
661661

662662
#initialize progress tracking by clearing out the temp files used to track
663663
init-progress() {
664-
if [ -d /tmp/backup-utils-progress ]; then
664+
665+
if [ -e /tmp/backup-utils-progress ]; then
665666
rm -rf /tmp/backup-utils-progress/*
666667
fi
667-
668-
mkdir -p /tmp/backup-utils-progress
669-
chmod -R 777 /tmp/backup-utils-progress
670-
671-
touch /tmp/backup-utils-progress/total
672-
touch /tmp/backup-utils-progress/type
673-
touch /tmp/backup-utils-progress/progress
674-
touch /tmp/backup-utils-progress/info
668+
# shellcheck disable=SC2174 # We are fine with -m only affecting the deepest directory
669+
mkdir -m 777 -p /tmp/backup-utils-progress
670+
touch /tmp/backup-utils-progress/{total,type,progress,info}
675671
}
676672

677673

test/test-ghe-backup.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1074,3 +1074,18 @@ begin_test "ghe-backup collects information on system where backup-utils is inst
10741074

10751075
)
10761076
end_test
1077+
1078+
# Check that backup-utils manages track-progress folder correctly
1079+
begin_test "ghe-backup manages progress tracking files properly"
1080+
(
1081+
set -e
1082+
1083+
if [ -e /tmp/backup-utils-progress ]; then
1084+
rm -rf /tmp/backup-utils-progress/*
1085+
fi
1086+
1087+
output=$(ghe-backup)
1088+
echo "$output" | grep -v "mkdir: cannot create directory /tmp/backup-utils-progress: File exists"
1089+
1090+
)
1091+
end_test

0 commit comments

Comments
 (0)