summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2016-09-21 08:36:50 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2016-09-29 22:07:24 +0200
commita48f8ccb131b059e6878efc647a8ebd5f887d7a7 (patch)
treed41b27681c5d58ac7a0ca2faca36b14f45ae6328
parentec5779c824f54f9bdc1303fb22e61b4d558ece39 (diff)
Add tests for mkpkglists
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
-rw-r--r--test/setup.sh5
-rwxr-xr-xtest/t2100-mkpkglists.sh47
2 files changed, 52 insertions, 0 deletions
diff --git a/test/setup.sh b/test/setup.sh
index 232b14d..85faba0 100644
--- a/test/setup.sh
+++ b/test/setup.sh
@@ -11,6 +11,7 @@ export PYTHONPATH
GIT_AUTH="$TOPLEVEL/git-interface/git-auth.py"
GIT_SERVE="$TOPLEVEL/git-interface/git-serve.py"
GIT_UPDATE="$TOPLEVEL/git-interface/git-update.py"
+MKPKGLISTS="$TOPLEVEL/scripts/mkpkglists.py"
# Create the configuration file and a dummy notification script.
cat >config <<-EOF
@@ -40,6 +41,10 @@ ssh-cmdline = ssh aur@aur.archlinux.org
[update]
max-blob-size = 256000
+
+[mkpkglists]
+packagesfile = packages.gz
+pkgbasefile = pkgbase.gz
EOF
cat >notify.sh <<-EOF
diff --git a/test/t2100-mkpkglists.sh b/test/t2100-mkpkglists.sh
new file mode 100755
index 0000000..a84a1b6
--- /dev/null
+++ b/test/t2100-mkpkglists.sh
@@ -0,0 +1,47 @@
+#!/bin/sh
+
+test_description='mkpkglists tests'
+
+. ./setup.sh
+
+test_expect_success 'Test package list generation with no packages.' '
+ echo "DELETE FROM Packages;" | sqlite3 aur.db &&
+ echo "DELETE FROM PackageBases;" | sqlite3 aur.db &&
+ "$MKPKGLISTS" &&
+ test $(zcat packages.gz | wc -l) -eq 1 &&
+ test $(zcat pkgbase.gz | wc -l) -eq 1
+'
+
+test_expect_success 'Test package list generation.' '
+ cat <<-EOD | sqlite3 aur.db &&
+ INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS) VALUES (1, "foobar", 1, 0, 0);
+ INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS) VALUES (2, "foobar2", 2, 0, 0);
+ INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS) VALUES (3, "foobar3", NULL, 0, 0);
+ INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS) VALUES (4, "foobar4", 1, 0, 0);
+ INSERT INTO Packages (ID, PackageBaseID, Name) VALUES (1, 1, "pkg1");
+ INSERT INTO Packages (ID, PackageBaseID, Name) VALUES (2, 1, "pkg2");
+ INSERT INTO Packages (ID, PackageBaseID, Name) VALUES (3, 1, "pkg3");
+ INSERT INTO Packages (ID, PackageBaseID, Name) VALUES (4, 2, "pkg4");
+ INSERT INTO Packages (ID, PackageBaseID, Name) VALUES (5, 3, "pkg5");
+ EOD
+ "$MKPKGLISTS" &&
+ cat <<-EOD >expected &&
+ foobar
+ foobar2
+ foobar4
+ EOD
+ gunzip pkgbase.gz &&
+ sed "/^#/d" pkgbase >actual &&
+ test_cmp actual expected &&
+ cat <<-EOD >expected &&
+ pkg1
+ pkg2
+ pkg3
+ pkg4
+ EOD
+ gunzip packages.gz &&
+ sed "/^#/d" packages >actual &&
+ test_cmp actual expected
+'
+
+test_done