mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Important note: Python tests will repeatedly clear out tables that they test against; for this reason, one should always run the shell tests first. The __init__.py file is necessary for coverage to collect data from the tests being run. At this point in FastAPI development, I'd like to encourage a few things going forward: 1. Any time you contribute to the FastAPI codebase, you **must** maintain equal or increased coverage on the overall source. Developers are highly appreciated for adding tests in your specific domain of addition or modification that may be missing coverage. Our goal is 100% coverage, and all newly added files **must** have 100% coverage through tests. 2. All source should be formatted with the autopep8 tool and kept within an 80 column width, with the exception of HTML templates. Signed-off-by: Kevin Morris <kevr@0cost.org>
65 lines
1.8 KiB
Bash
Executable file
65 lines
1.8 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
test_description='mkpkglists tests'
|
|
|
|
. "$(dirname "$0")/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 &&
|
|
cover "$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, FlaggerComment) VALUES (1, "foobar", 1, 0, 0, "");
|
|
INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (2, "foobar2", 2, 0, 0, "");
|
|
INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (3, "foobar3", NULL, 0, 0, "");
|
|
INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS, FlaggerComment) 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
|
|
cover "$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_expect_success 'Test user list generation.' '
|
|
cover "$MKPKGLISTS" &&
|
|
cat <<-EOD >expected &&
|
|
dev
|
|
tu
|
|
tu2
|
|
tu3
|
|
tu4
|
|
user
|
|
user2
|
|
user3
|
|
user4
|
|
EOD
|
|
gunzip users.gz &&
|
|
sed "/^#/d" users >actual &&
|
|
test_cmp actual expected
|
|
'
|
|
|
|
test_done
|