Added test for the config_debs function to test the parameter count for the dpkg...
authorUlrich Dangel <mru@grml.org>
Fri, 15 Oct 2010 17:44:48 +0000 (19:44 +0200)
committerUlrich Dangel <mru@grml.org>
Fri, 15 Oct 2010 17:44:48 +0000 (19:44 +0200)
tests/test_debs.sh [new file with mode: 0755]

diff --git a/tests/test_debs.sh b/tests/test_debs.sh
new file mode 100755 (executable)
index 0000000..a1f5aa3
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/zsh
+# This test does not use shunit2 as shunit2 requires shwordsplit
+# But shwordsplit is not enabled per default in zsh and needs to be
+# taken care of in autoconfig.functions.
+
+EXPECTED_COUNT=4
+dpkg() {
+    # remove the -i parameter
+    shift
+
+    if [ $# -ne $EXPECTED_COUNT ] ; then
+        echo "wrong parameter count for dpkg, was $# expected $EXPECTED_COUNT" >&2
+        exit 1
+    fi
+}
+
+test_debs() {
+    . ../autoconfig.functions
+    CMDLINE='debs=*'
+    INSTALLED=''
+
+    TMPDIR=$(mktemp -d)
+    DCSDIR="$TMPDIR"
+    DEB_DIR="$DCSDIR"/debs
+    mkdir -p "$DEB_DIR"
+    touch "$DEB_DIR"/{1..$EXPECTED_COUNT}.deb
+
+    config_debs
+
+    rm -rf "$TMPDIR"
+}
+
+test_debs