[aur-dev] [PATCH 1/3] t1300: Factor out package dumping
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- test/t1300-git-update.sh | 36 ++++++++++++------------------------ 1 file changed, 12 insertions(+), 24 deletions(-) diff --git a/test/t1300-git-update.sh b/test/t1300-git-update.sh index a65ca3a..dbe6029 100755 --- a/test/t1300-git-update.sh +++ b/test/t1300-git-update.sh @@ -4,6 +4,14 @@ test_description='git-update tests' . ./setup.sh +dump_package_info() { + for t in Packages Licenses PackageLicenses Groups PackageGroups \ + PackageDepends PackageRelations PackageSources \ + PackageNotifications; do + echo "SELECT * FROM $t;" | sqlite3 aur.db + done +} + test_expect_success 'Test update hook on a fresh repository.' ' old=0000000000000000000000000000000000000000 && new=$(git -C aur.git rev-parse HEAD^) && @@ -16,12 +24,7 @@ test_expect_success 'Test update hook on a fresh repository.' ' 1|1|python-pygit2|| 1|1 EOF - >actual && - for t in Packages Licenses PackageLicenses Groups PackageGroups \ - PackageDepends PackageRelations PackageSources \ - PackageNotifications; do - echo "SELECT * FROM $t;" | sqlite3 aur.db >>actual - done && + dump_package_info >actual && test_cmp expected actual ' @@ -44,12 +47,7 @@ test_expect_success 'Test update hook on another fresh repository.' ' 1|1 2|1 EOF - >actual && - for t in Packages Licenses PackageLicenses Groups PackageGroups \ - PackageDepends PackageRelations PackageSources \ - PackageNotifications; do - echo "SELECT * FROM $t;" | sqlite3 aur.db >>actual - done && + dump_package_info >actual && test_cmp expected actual ' @@ -70,12 +68,7 @@ test_expect_success 'Test update hook on an updated repository.' ' 1|1 2|1 EOF - >actual && - for t in Packages Licenses PackageLicenses Groups PackageGroups \ - PackageDepends PackageRelations PackageSources \ - PackageNotifications; do - echo "SELECT * FROM $t;" | sqlite3 aur.db >>actual - done && + dump_package_info >actual && test_cmp expected actual ' @@ -94,12 +87,7 @@ test_expect_success 'Test restore mode.' ' 1|1 2|1 EOF - >actual && - for t in Packages Licenses PackageLicenses Groups PackageGroups \ - PackageDepends PackageRelations PackageSources \ - PackageNotifications; do - echo "SELECT * FROM $t;" | sqlite3 aur.db >>actual - done && + dump_package_info >actual && test_cmp expected actual ' -- 2.12.2
Since commit 09cb61a (schema: Remove invalid default values for TEXT columns, 2017-04-15), the PackageBases.FlaggerComment field no longer has a default value. Initialize this field explicitly whenever a new row is added to the PackageBases table. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- aurweb/git/serve.py | 5 +++-- aurweb/git/update.py | 5 +++-- test/t1300-git-update.sh | 14 +++++++------- test/t2100-mkpkglists.sh | 8 ++++---- test/t2300-pkgmaint.sh | 8 ++++---- test/t2500-notify.sh | 8 ++++---- 6 files changed, 25 insertions(+), 23 deletions(-) diff --git a/aurweb/git/serve.py b/aurweb/git/serve.py index 44cce75..3eef26a 100755 --- a/aurweb/git/serve.py +++ b/aurweb/git/serve.py @@ -65,8 +65,9 @@ def create_pkgbase(pkgbase, user): now = int(time.time()) cur = conn.execute("INSERT INTO PackageBases (Name, SubmittedTS, " + - "ModifiedTS, SubmitterUID, MaintainerUID) VALUES " + - "(?, ?, ?, ?, ?)", [pkgbase, now, now, userid, userid]) + "ModifiedTS, SubmitterUID, MaintainerUID, " + + "FlaggerComment) VALUES (?, ?, ?, ?, ?, '')", + [pkgbase, now, now, userid, userid]) pkgbase_id = cur.lastrowid cur = conn.execute("INSERT INTO PackageNotifications " + diff --git a/aurweb/git/update.py b/aurweb/git/update.py index 09a57ef..c9a98d0 100755 --- a/aurweb/git/update.py +++ b/aurweb/git/update.py @@ -61,8 +61,9 @@ def create_pkgbase(conn, pkgbase, user): now = int(time.time()) cur = conn.execute("INSERT INTO PackageBases (Name, SubmittedTS, " + - "ModifiedTS, SubmitterUID, MaintainerUID) VALUES " + - "(?, ?, ?, ?, ?)", [pkgbase, now, now, userid, userid]) + "ModifiedTS, SubmitterUID, MaintainerUID, " + + "FlaggerComment) VALUES (?, ?, ?, ?, ?, '')", + [pkgbase, now, now, userid, userid]) pkgbase_id = cur.lastrowid cur = conn.execute("INSERT INTO PackageNotifications " + diff --git a/test/t1300-git-update.sh b/test/t1300-git-update.sh index dbe6029..f16e2ad 100755 --- a/test/t1300-git-update.sh +++ b/test/t1300-git-update.sh @@ -21,7 +21,7 @@ test_expect_success 'Test update hook on a fresh repository.' ' 1|1|foobar|1-1|aurweb test package.|https://aur.archlinux.org/ 1|GPL 1|1 - 1|1|python-pygit2|| + 1|1|python-pygit2||| 1|1 EOF dump_package_info >actual && @@ -42,8 +42,8 @@ test_expect_success 'Test update hook on another fresh repository.' ' 2|MIT 1|1 2|2 - 1|1|python-pygit2|| - 2|1|python-pygit2|| + 1|1|python-pygit2||| + 2|1|python-pygit2||| 1|1 2|1 EOF @@ -63,8 +63,8 @@ test_expect_success 'Test update hook on an updated repository.' ' 2|MIT 2|2 3|1 - 2|1|python-pygit2|| - 3|1|python-pygit2|| + 2|1|python-pygit2||| + 3|1|python-pygit2||| 1|1 2|1 EOF @@ -82,8 +82,8 @@ test_expect_success 'Test restore mode.' ' 2|MIT 2|2 3|1 - 2|1|python-pygit2|| - 3|1|python-pygit2|| + 2|1|python-pygit2||| + 3|1|python-pygit2||| 1|1 2|1 EOF diff --git a/test/t2100-mkpkglists.sh b/test/t2100-mkpkglists.sh index a84a1b6..1e2edc3 100755 --- a/test/t2100-mkpkglists.sh +++ b/test/t2100-mkpkglists.sh @@ -14,10 +14,10 @@ test_expect_success 'Test package list generation with no packages.' ' 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 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"); diff --git a/test/t2300-pkgmaint.sh b/test/t2300-pkgmaint.sh index 5c55aaf..478df52 100755 --- a/test/t2300-pkgmaint.sh +++ b/test/t2300-pkgmaint.sh @@ -8,10 +8,10 @@ test_expect_success 'Test package base cleanup script.' ' now=$(date -d now +%s) && threedaysago=$(date -d "3 days ago" +%s) && cat <<-EOD | sqlite3 aur.db && - INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS) VALUES (1, "foobar", 1, $now, 0); - INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS) VALUES (2, "foobar2", 2, $threedaysago, 0); - INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS) VALUES (3, "foobar3", NULL, $now, 0); - INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS) VALUES (4, "foobar4", NULL, $threedaysago, 0); + INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (1, "foobar", 1, $now, 0, ""); + INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (2, "foobar2", 2, $threedaysago, 0, ""); + INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (3, "foobar3", NULL, $now, 0, ""); + INSERT INTO PackageBases (ID, Name, PackagerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (4, "foobar4", NULL, $threedaysago, 0, ""); EOD "$PKGMAINT" && cat <<-EOD >expected && diff --git a/test/t2500-notify.sh b/test/t2500-notify.sh index 1b20945..3997682 100755 --- a/test/t2500-notify.sh +++ b/test/t2500-notify.sh @@ -6,10 +6,10 @@ test_description='notify tests' test_expect_success 'Test out-of-date notifications.' ' cat <<-EOD | sqlite3 aur.db && - INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS) VALUES (1, "foobar", 1, 0, 0); - INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS) VALUES (2, "foobar2", 2, 0, 0); - INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS) VALUES (3, "foobar3", NULL, 0, 0); - INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS) VALUES (4, "foobar4", 1, 0, 0); + INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (1, "foobar", 1, 0, 0, ""); + INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (2, "foobar2", 2, 0, 0, ""); + INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (3, "foobar3", NULL, 0, 0, ""); + INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (4, "foobar4", 1, 0, 0, ""); INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (1, 2, 1); INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (1, 4, 2); INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (2, 3, 1); -- 2.12.2
Since commit 09cb61a (schema: Remove invalid default values for TEXT columns, 2017-04-15), the PackageRequests.Comments and PackageRequests.ClosureComment fields no longer have a default value. Initialize these fields explicitly whenever a new row is added to the PackageRequests table. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org> --- test/t1200-git-serve.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/t1200-git-serve.sh b/test/t1200-git-serve.sh index 07383af..038a798 100755 --- a/test/t1200-git-serve.sh +++ b/test/t1200-git-serve.sh @@ -353,9 +353,9 @@ test_expect_success "Check whether package requests are closed when disowning." SSH_ORIGINAL_COMMAND="adopt foobar" AUR_USER=user AUR_PRIVILEGED=0 \ "$GIT_SERVE" 2>&1 && cat <<-EOD | sqlite3 aur.db && - INSERT INTO PackageRequests (ID, ReqTypeID, PackageBaseID, PackageBaseName, UsersID) VALUES (1, 2, 3, "foobar", 4); - INSERT INTO PackageRequests (ID, ReqTypeID, PackageBaseID, PackageBaseName, UsersID) VALUES (2, 3, 3, "foobar", 5); - INSERT INTO PackageRequests (ID, ReqTypeID, PackageBaseID, PackageBaseName, UsersID) VALUES (3, 2, 2, "foobar2", 6); + INSERT INTO PackageRequests (ID, ReqTypeID, PackageBaseID, PackageBaseName, UsersID, Comments, ClosureComment) VALUES (1, 2, 3, "foobar", 4, "", ""); + INSERT INTO PackageRequests (ID, ReqTypeID, PackageBaseID, PackageBaseName, UsersID, Comments, ClosureComment) VALUES (2, 3, 3, "foobar", 5, "", ""); + INSERT INTO PackageRequests (ID, ReqTypeID, PackageBaseID, PackageBaseName, UsersID, Comments, ClosureComment) VALUES (3, 2, 2, "foobar2", 6, "", ""); EOD >sendmail.out && SSH_ORIGINAL_COMMAND="disown foobar" AUR_USER=user AUR_PRIVILEGED=0 \ -- 2.12.2
participants (1)
-
Lukas Fleischer