summaryrefslogtreecommitdiff
path: root/test/integration/test-apt-extracttemplates
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2014-11-08 22:23:19 +0100
committerDavid Kalnischkies <david@kalnischkies.de>2014-11-09 21:45:55 +0100
commit061ee5f0efa9d8e8fe4796c13af68fe282a21073 (patch)
treebf1952570aacd5ea6182aa7d94fc9ba12149105f /test/integration/test-apt-extracttemplates
parentd9e518c6f7dc0ad464495b586d1b8e115d54d41a (diff)
enhance apt-extracttemplates test
The tool checks for debconf version before printing the info it extracts, so that it doesn't extract data which can't be interpreted before debconf is upgraded. It is only fair to check for this behaviour in the tests. Git-Dch: Ignore
Diffstat (limited to 'test/integration/test-apt-extracttemplates')
-rwxr-xr-xtest/integration/test-apt-extracttemplates69
1 files changed, 47 insertions, 22 deletions
diff --git a/test/integration/test-apt-extracttemplates b/test/integration/test-apt-extracttemplates
index ae2cc8bc2..276862464 100755
--- a/test/integration/test-apt-extracttemplates
+++ b/test/integration/test-apt-extracttemplates
@@ -8,38 +8,63 @@ setupenvironment
configarchitecture 'amd64'
# apt-extracttemplates needs this
-insertinstalledpackage 'debconf' 'amd64' '1.5'
insertinstalledpackage 'pkg-with-template' 'amd64' '1.0'
# build a simple package that contains a config and a tempalte
mkdir -p DEBIAN
-TEMPLATE_STR="Template: foo/bar
-Type: string
-Description: Some bar var
-"
-echo "$TEMPLATE_STR" > DEBIAN/templates
-
CONFIG_STR="#!/bin/sh
random shell stuff
"
echo "$CONFIG_STR" > DEBIAN/config
-buildsimplenativepackage 'pkg-with-template' 'amd64' '0.8.15' 'stable' '' 'pkg with template' '' '' './DEBIAN'
+testrun() {
+ local TEMPLATE_STR='Template: foo/bar
+Type: string
+Description: Some bar var
+'
+ echo "$TEMPLATE_STR" > DEBIAN/templates
+ buildsimplenativepackage "$1" 'amd64' '0.8.15' 'stable' "$2" 'pkg with template' '' '' './DEBIAN'
+
+ cp dpkg.status rootdir/var/lib/dpkg/status
+ insertinstalledpackage 'debconf' 'amd64' '3'
+
+ # ensure we get the right stuff out of the file
+ rm -rf extracttemplates-out rootdir/var/cache/apt
+ mkdir extracttemplates-out
+ testsuccess aptextracttemplates -t ./extracttemplates-out incoming/${1}*.deb
+ OUT='rootdir/tmp/testsuccess.output'
+ testequal "$1" cut -f1 -d' ' $OUT
+ if [ -n "$2" ]; then
+ testequal '' cut -f2 -d' ' $OUT
+ else
+ testequal '1.0' cut -f2 -d' ' $OUT
+ fi
+ TEMPLATE=$(cut -f3 -d' ' $OUT)
+ testfileequal "$TEMPLATE" "$TEMPLATE_STR"
+ CONFIG=$(cut -f4 -d' ' $OUT)
+ testfileequal "$CONFIG" "$CONFIG_STR"
-# ensure we get the right stuff out of the file
-mkdir extracttemplates-out
-OUT="$(aptextracttemplates -t ./extracttemplates-out incoming/pkg-with-template*.deb)"
+ # ensure that the format of the output string has the right number of dots
+ for s in "$CONFIG" "$TEMPLATE"; do
+ NR_DOTS=$(basename "$s" | tr -c -d '.')
+ testequal '..' echo $NR_DOTS
+ done
-PKG=$(printf "$OUT" | cut -f1 -d' ')
-INSTALLED_VER=$(printf "$OUT" | cut -f2 -d' ')
-TEMPLATE=$(printf "$OUT" | cut -f3 -d' ')
-CONFIG=$(printf "$OUT" | cut -f4 -d' ')
+ if [ -n "$2" ]; then
+ rm -rf extracttemplates-out rootdir/var/cache/apt
+ mkdir extracttemplates-out
+ cp dpkg.status rootdir/var/lib/dpkg/status
+ insertinstalledpackage 'debconf' 'amd64' '1'
+ testempty aptextracttemplates -t ./extracttemplates-out incoming/${1}*.deb
+ fi
+}
-testequal "$CONFIG_STR" cat $CONFIG
-testequal "$TEMPLATE_STR" cat $TEMPLATE
+cp rootdir/var/lib/dpkg/status dpkg.status
+testrun 'pkg-with-template' ''
+testrun 'pkg-with-template-depends' 'Depends: debconf (>= 2)'
+testrun 'pkg-with-template-predepends' 'Pre-Depends: debconf (>= 2)'
-# ensure that the format of the output string has the right number of dots
-for s in "$CONFIG" "$TEMPLATE"; do
- NR_DOTS=$(basename "$s" | tr -c -d .)
- testequal ".." echo $NR_DOTS
-done
+# test with no debconf installed
+cp dpkg.status rootdir/var/lib/dpkg/status
+testfailure aptextracttemplates -t ./extracttemplates-out incoming/pkg-with-template-depends*.deb
+testfileequal 'rootdir/tmp/testfailure.output' 'E: Cannot get debconf version. Is debconf installed?'