tests: improve setconfig_repeat

This commit is contained in:
Jerome Charaoui 2021-01-05 23:45:06 -05:00
parent b3ca5e956c
commit 5bc6b9c1b5
3 changed files with 11 additions and 9 deletions

View File

@ -137,7 +137,7 @@ finish_borg() {
greplog 'Debug: executing borg create$' "'${BN_SRCDIR}'$" greplog 'Debug: executing borg create$' "'${BN_SRCDIR}'$"
# multiple paths # multiple paths
setconfig_repeat backup.d/test.borg include "$BN_SRCDIR" /foo /bar setconfig_repeat backup.d/test.borg source include "$BN_SRCDIR" /foo /bar
testaction test.borg testaction test.borg
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
greplog 'Debug: executing borg create$' "'${BN_SRCDIR}' '/foo' '/bar'$" greplog 'Debug: executing borg create$' "'${BN_SRCDIR}' '/foo' '/bar'$"
@ -157,7 +157,7 @@ finish_borg() {
greplog 'Debug: executing borg create$' "\s--exclude '${BN_SRCDIR}/var'\s" greplog 'Debug: executing borg create$' "\s--exclude '${BN_SRCDIR}/var'\s"
# multiple paths # multiple paths
setconfig_repeat backup.d/test.borg exclude "$BN_SRCDIR/var" "$BN_SRCDIR/foo" "$BN_SRCDIR/bar" setconfig_repeat backup.d/test.borg source exclude "$BN_SRCDIR/var" "$BN_SRCDIR/foo" "$BN_SRCDIR/bar"
testaction test.borg testaction test.borg
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
greplog 'Debug: executing borg create$' "\s--exclude '${BN_SRCDIR}/var' --exclude '${BN_SRCDIR}/foo' --exclude '${BN_SRCDIR}/bar'\s" greplog 'Debug: executing borg create$' "\s--exclude '${BN_SRCDIR}/var' --exclude '${BN_SRCDIR}/foo' --exclude '${BN_SRCDIR}/bar'\s"

View File

@ -95,12 +95,14 @@ setconfig() {
# (used for include and exclude parameters) # (used for include and exclude parameters)
setconfig_repeat() { setconfig_repeat() {
conffile="${BATS_TMPDIR}/$1" conffile="${BATS_TMPDIR}/$1"
param="$2" section="$2"
shift; shift; param="$3"
for p in "$@"; do shift 3
conf="${conf}${param} = ${p}\n" crudini --del "$conffile" "$section" "$param"
for v; do
crudini --set --list --list-sep=$'\nREPEAT = ' "$conffile" "$section" "$param" "$v"
done done
sed -i "s#^${param} =.*#${conf}#" "${conffile}" sed -i "s#^\s\+REPEAT =#${param} =#" "${conffile}"
} }
# delete config parameter # delete config parameter

View File

@ -141,7 +141,7 @@ finish_dup() {
greplog 'Debug: executing duplicity$' "\s--include '${BN_SRCDIR}'" greplog 'Debug: executing duplicity$' "\s--include '${BN_SRCDIR}'"
# multiple paths # multiple paths
setconfig_repeat backup.d/test.dup include "$BN_SRCDIR" /foo /bar setconfig_repeat backup.d/test.dup source include "$BN_SRCDIR" /foo /bar
testaction test.dup testaction test.dup
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
greplog 'Debug: executing duplicity$' "\s--include '${BN_SRCDIR}' --include '/foo' --include '/bar'\s" greplog 'Debug: executing duplicity$' "\s--include '${BN_SRCDIR}' --include '/foo' --include '/bar'\s"
@ -161,7 +161,7 @@ finish_dup() {
greplog 'Debug: executing duplicity$' "\s--exclude '${BN_SRCDIR}/var'\s" greplog 'Debug: executing duplicity$' "\s--exclude '${BN_SRCDIR}/var'\s"
# multiple paths # multiple paths
setconfig_repeat backup.d/test.dup exclude "$BN_SRCDIR/var" "$BN_SRCDIR/foo" "$BN_SRCDIR/bar" setconfig_repeat backup.d/test.dup source exclude "$BN_SRCDIR/var" "$BN_SRCDIR/foo" "$BN_SRCDIR/bar"
testaction test.dup testaction test.dup
[ "$status" -eq 0 ] [ "$status" -eq 0 ]
greplog 'Debug: executing duplicity$' "\s--exclude '${BN_SRCDIR}/var' --exclude '${BN_SRCDIR}/foo' --exclude '${BN_SRCDIR}/bar'\s" greplog 'Debug: executing duplicity$' "\s--exclude '${BN_SRCDIR}/var' --exclude '${BN_SRCDIR}/foo' --exclude '${BN_SRCDIR}/bar'\s"