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
No related tags found
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
...
@@ -2,8 +2,8 @@ load common
begin_tar() {
begin_tar() {
apt-get -qq install debootstrap ncompress zstd
apt-get -qq install debootstrap ncompress zstd
if [ ! -d
/var/cache/bntest
]; then
if [ ! -d
"$BN_SRCDIR"
]; then
debootstrap --variant=minbase testing
/var/cache/bntest
debootstrap --variant=minbase testing
"$BN_SRCDIR"
fi
fi
}
}
...
@@ -11,10 +11,10 @@ setup_tar() {
...
@@ -11,10 +11,10 @@ setup_tar() {
cat << EOF > "${BATS_TMPDIR}/backup.d/test.tar"
cat << EOF > "${BATS_TMPDIR}/backup.d/test.tar"
when = manual
when = manual
backupname = bntest
backupname = bntest
backupdir =
/var/backups
/tartest
backupdir =
${BN_BACKUPDIR}
/tartest
compress = none
compress = none
includes =
/var/cache/bntest
includes =
$BN_SRCDIR
excludes =
/var/cache/bntest
/var
excludes =
${BN_SRCDIR}
/var
EOF
EOF
chmod 0640 "${BATS_TMPDIR}/backup.d/test.tar"
chmod 0640 "${BATS_TMPDIR}/backup.d/test.tar"
...
@@ -26,9 +26,8 @@ teardown_tar() {
...
@@ -26,9 +26,8 @@ teardown_tar() {
@test "no compression" {
@test "no compression" {
runaction
runaction
grep -q "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning." "${BATS_TMPDIR}/log/backupninja.log"
greplog "Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
archive=$(find /var/backups/tartest -maxdepth 1 -name bntest-\*.tar)
archive=$(find "${BN_BACKUPDIR}/tartest" -maxdepth 1 -name bntest-\*.tar)
echo $archive
[ -s "$archive" ]
[ -s "$archive" ]
tar xOf "$archive" &> /dev/null
tar xOf "$archive" &> /dev/null
}
}
...
@@ -36,8 +35,8 @@ teardown_tar() {
...
@@ -36,8 +35,8 @@ teardown_tar() {
@test "compress compression" {
@test "compress compression" {
setconfig compress compress
setconfig compress compress
runaction
runaction
grep
-q
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
"${BATS_TMPDIR}/log/backupninja.log"
grep
log
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
archive=$(find
/var/backups
/tartest -maxdepth 1 -name bntest-\*.tar.compress)
archive=$(find
"${BN_BACKUPDIR}
/tartest
"
-maxdepth 1 -name bntest-\*.tar.compress)
[ -s "$archive" ]
[ -s "$archive" ]
tar xZOf "$archive" &> /dev/null
tar xZOf "$archive" &> /dev/null
}
}
...
@@ -45,8 +44,8 @@ teardown_tar() {
...
@@ -45,8 +44,8 @@ teardown_tar() {
@test "gzip compression" {
@test "gzip compression" {
setconfig compress gzip
setconfig compress gzip
runaction
runaction
grep
-q
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
"${BATS_TMPDIR}/log/backupninja.log"
grep
log
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
archive=$(find
/var/backups
/tartest -maxdepth 1 -name bntest-\*.tgz)
archive=$(find
"${BN_BACKUPDIR}
/tartest
"
-maxdepth 1 -name bntest-\*.tgz)
[ -s "$archive" ]
[ -s "$archive" ]
tar xzOf "$archive" &> /dev/null
tar xzOf "$archive" &> /dev/null
}
}
...
@@ -54,8 +53,8 @@ teardown_tar() {
...
@@ -54,8 +53,8 @@ teardown_tar() {
@test "bzip2 compression" {
@test "bzip2 compression" {
setconfig compress bzip
setconfig compress bzip
runaction
runaction
grep
-q
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
"${BATS_TMPDIR}/log/backupninja.log"
grep
log
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
archive=$(find
/var/backups
/tartest -maxdepth 1 -name bntest-\*.tar.bz2)
archive=$(find
"${BN_BACKUPDIR}
/tartest
"
-maxdepth 1 -name bntest-\*.tar.bz2)
[ -s "$archive" ]
[ -s "$archive" ]
tar xjOf "$archive" &> /dev/null
tar xjOf "$archive" &> /dev/null
}
}
...
@@ -63,8 +62,8 @@ teardown_tar() {
...
@@ -63,8 +62,8 @@ teardown_tar() {
@test "xz compression" {
@test "xz compression" {
setconfig compress xz
setconfig compress xz
runaction
runaction
grep
-q
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
"${BATS_TMPDIR}/log/backupninja.log"
grep
log
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
archive=$(find
/var/backups
/tartest -maxdepth 1 -name bntest-\*.tar.xz)
archive=$(find
"${BN_BACKUPDIR}
/tartest
"
-maxdepth 1 -name bntest-\*.tar.xz)
[ -s "$archive" ]
[ -s "$archive" ]
tar xJOf "$archive" &> /dev/null
tar xJOf "$archive" &> /dev/null
}
}
...
@@ -72,8 +71,8 @@ teardown_tar() {
...
@@ -72,8 +71,8 @@ teardown_tar() {
@test "zstd compression" {
@test "zstd compression" {
setconfig compress zstd
setconfig compress zstd
runaction
runaction
grep
-q
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
"${BATS_TMPDIR}/log/backupninja.log"
grep
log
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 0 warning."
archive=$(find
/var/backups
/tartest -maxdepth 1 -name bntest-\*.tar.zst)
archive=$(find
"${BN_BACKUPDIR}
/tartest
"
-maxdepth 1 -name bntest-\*.tar.zst)
[ -s "$archive" ]
[ -s "$archive" ]
tar --zstd -xOf "$archive" &> /dev/null
tar --zstd -xOf "$archive" &> /dev/null
}
}
...
@@ -81,8 +80,8 @@ teardown_tar() {
...
@@ -81,8 +80,8 @@ teardown_tar() {
@test "unknown compression, defaults to gzip" {
@test "unknown compression, defaults to gzip" {
setconfig compress foo
setconfig compress foo
runaction
runaction
grep
-q
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 1 warning."
"${BATS_TMPDIR}/log/backupninja.log"
grep
log
"Info: FINISHED: 1 actions run. 0 fatal. 0 error. 1 warning."
archive=$(find
/var/backups
/tartest -maxdepth 1 -name bntest-\*.tgz)
archive=$(find
"${BN_BACKUPDIR}
/tartest
"
-maxdepth 1 -name bntest-\*.tgz)
[ -s "$archive" ]
[ -s "$archive" ]
tar xzOf "$archive" &> /dev/null
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