summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@derf.homelinux.org>2009-04-10 22:41:28 +0200
committerDaniel Friesel <derf@derf.homelinux.org>2009-04-10 22:41:28 +0200
commit9ae5f36e46584f1f24c2e8fdf30d2754f92caf3e (patch)
tree1e5804071d1639fff5e498d7111440891a70419a
parent34badfbe0285e92d4f1fcedca2455e6fc1f3eb3e (diff)
Added tests for pkg add, extended tests for pkg list
-rwxr-xr-xbin/pkg2
-rwxr-xr-xtest/main26
2 files changed, 25 insertions, 3 deletions
diff --git a/bin/pkg b/bin/pkg
index ec143b5..5c7e971 100755
--- a/bin/pkg
+++ b/bin/pkg
@@ -658,7 +658,7 @@ function wrap {
function pkg_add {
if [[ -d $PDIR/$1 ]] {
info "Package '$1' is already installed!\n"
- return 100
+ exit 1
}
list_exists $1 || die "No such package: $1\n"
info "Retrieving package $1...\n"
diff --git a/test/main b/test/main
index feb2471..0938970 100755
--- a/test/main
+++ b/test/main
@@ -40,8 +40,8 @@ echo "# checking for success"
[[ -d $test_pdir/core ]]
echo "# pkg list local"
-stringcmp "core" $(pkg list)
-stringcmp "core" $(pkg list local)
+stringcmp "core" "$(pkg list)"
+stringcmp "core" "$(pkg list local)"
echo "# pkg list not-installed"
stringcmp "ra\nrb\nrc" "$(pkg list not-installed)"
@@ -49,6 +49,28 @@ stringcmp "ra\nrb\nrc" "$(pkg list not-installed)"
echo "# pkg list all"
stringcmp "core\nra\nrb\nrc" "$(pkg list all)"
+echo "# pkg add (no such repo)"
+! pkg add weltfrieden
+
+echo "# pkg add (already installed)"
+! pkg add core
+
+echo "# pkg add (ok)"
+pkg add ra
+[[ -e $test_pdir/ra/foo ]]
+[[ -d $test_pdir/ra/.git ]]
+
+echo "# pkg add (already installed)"
+! pkg add ra
+
+repeat 2 {
+ echo "# pkg list"
+ stringcmp "core\nra" "$(pkg list local)"
+ stringcmp "rb\nrc" "$(pkg list not-installed)"
+ stringcmp "core\nra\nrb\nrc" "$(pkg list remote)"
+ pkg update
+}
+
rm -rf $test_pdir $test_proot $test_home
print -P '%F{green} test passed%F{default}'