Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
backupninja
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Liberate
backupninja
Commits
5bcaea00
Commit
5bcaea00
authored
4 years ago
by
Jérôme Charaoui
Browse files
Options
Downloads
Patches
Plain Diff
tests: use globals and common functions in tar test
parent
3733864b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!46
Add a testsuite
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/tar.bats
+19
-20
19 additions, 20 deletions
test/tar.bats
with
19 additions
and
20 deletions
test/tar.bats
+
19
−
20
View file @
5bcaea00
...
...
@@ -2,8 +2,8 @@ load common
begin_tar() {
apt-get -qq install debootstrap ncompress zstd
if [ ! -d
/var/cache/bntest
]; then
debootstrap --variant=minbase testing
/var/cache/bntest
if [ ! -d
"$BN_SRCDIR"
]; then
debootstrap --variant=minbase testing
"$BN_SRCDIR"
fi
}
...
...
@@ -11,10 +11,10 @@ setup_tar() {
cat << EOF > "${BATS_TMPDIR}/backup.d/test.tar"
when = manual
backupname = bntest
backupdir =
/var/backups
/tartest
backupdir =
${BN_BACKUPDIR}
/tartest
compress = none
includes =
/var/cache/bntest
excludes =
/var/cache/bntest
/var
includes =
$BN_SRCDIR
excludes =
${BN_SRCDIR}
/var
EOF
chmod 0640 "${BATS_TMPDIR}/backup.d/test.tar"
...
...
@@ -26,9 +26,8 @@ teardown_tar() {
@test "no compression" {
runaction
grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning." "${BATS_TMPDIR}/log/backupninja.log"
archive=$(find /var/backups/tartest -maxdepth 1 -name bntest-\*.tar)
echo $archive
greplog "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
archive=$(find "${BN_BACKUPDIR}/tartest" -maxdepth 1 -name bntest-\*.tar)
[ -s "$archive" ]
tar xOf "$archive" &> /dev/null
}
...
...
@@ -36,8 +35,8 @@ teardown_tar() {
@test "compress compression" {
setconfig compress compress
runaction
grep
-q
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
"${BATS_TMPDIR}/log/backupninja.log"
archive=$(find
/var/backups
/tartest -maxdepth 1 -name bntest-\*.tar.compress)
grep
log
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
archive=$(find
"${BN_BACKUPDIR}
/tartest
"
-maxdepth 1 -name bntest-\*.tar.compress)
[ -s "$archive" ]
tar xZOf "$archive" &> /dev/null
}
...
...
@@ -45,8 +44,8 @@ teardown_tar() {
@test "gzip compression" {
setconfig compress gzip
runaction
grep
-q
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
"${BATS_TMPDIR}/log/backupninja.log"
archive=$(find
/var/backups
/tartest -maxdepth 1 -name bntest-\*.tgz)
grep
log
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
archive=$(find
"${BN_BACKUPDIR}
/tartest
"
-maxdepth 1 -name bntest-\*.tgz)
[ -s "$archive" ]
tar xzOf "$archive" &> /dev/null
}
...
...
@@ -54,8 +53,8 @@ teardown_tar() {
@test "bzip2 compression" {
setconfig compress bzip
runaction
grep
-q
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
"${BATS_TMPDIR}/log/backupninja.log"
archive=$(find
/var/backups
/tartest -maxdepth 1 -name bntest-\*.tar.bz2)
grep
log
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
archive=$(find
"${BN_BACKUPDIR}
/tartest
"
-maxdepth 1 -name bntest-\*.tar.bz2)
[ -s "$archive" ]
tar xjOf "$archive" &> /dev/null
}
...
...
@@ -63,8 +62,8 @@ teardown_tar() {
@test "xz compression" {
setconfig compress xz
runaction
grep
-q
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
"${BATS_TMPDIR}/log/backupninja.log"
archive=$(find
/var/backups
/tartest -maxdepth 1 -name bntest-\*.tar.xz)
grep
log
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
archive=$(find
"${BN_BACKUPDIR}
/tartest
"
-maxdepth 1 -name bntest-\*.tar.xz)
[ -s "$archive" ]
tar xJOf "$archive" &> /dev/null
}
...
...
@@ -72,8 +71,8 @@ teardown_tar() {
@test "zstd compression" {
setconfig compress zstd
runaction
grep
-q
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
"${BATS_TMPDIR}/log/backupninja.log"
archive=$(find
/var/backups
/tartest -maxdepth 1 -name bntest-\*.tar.zst)
grep
log
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
archive=$(find
"${BN_BACKUPDIR}
/tartest
"
-maxdepth 1 -name bntest-\*.tar.zst)
[ -s "$archive" ]
tar --zstd -xOf "$archive" &> /dev/null
}
...
...
@@ -81,8 +80,8 @@ teardown_tar() {
@test "unknown compression, defaults to gzip" {
setconfig compress foo
runaction
grep
-q
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 1 warning."
"${BATS_TMPDIR}/log/backupninja.log"
archive=$(find
/var/backups
/tartest -maxdepth 1 -name bntest-\*.tgz)
grep
log
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 1 warning."
archive=$(find
"${BN_BACKUPDIR}
/tartest
"
-maxdepth 1 -name bntest-\*.tgz)
[ -s "$archive" ]
tar xzOf "$archive" &> /dev/null
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment