t2500: use unique identifiers

Use disjoint sets of IDs for users, package bases, package comments and
package requests to ensure the notification script expects the
parameters in the same order we pass them.

Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
Lukas Fleischer 2018-08-12 13:24:08 +02:00
parent bf5a79da6b
commit 0ae1ca15e9

View file

@ -6,18 +6,19 @@ test_description='notify tests'
test_expect_success 'Test out-of-date notifications.' ' test_expect_success 'Test out-of-date notifications.' '
cat <<-EOD | sqlite3 aur.db && cat <<-EOD | sqlite3 aur.db &&
INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (1, "foobar", 1, 0, 0, "This is a test OOD comment."); /* Use package base IDs which can be distinguished from user IDs. */
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 (1001, "foobar", 1, 0, 0, "This is a test OOD comment.");
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 (1002, "foobar2", 2, 0, 0, "");
INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (4, "foobar4", 1, 0, 0, ""); INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (1003, "foobar3", NULL, 0, 0, "");
INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (1, 2, 1); INSERT INTO PackageBases (ID, Name, MaintainerUID, SubmittedTS, ModifiedTS, FlaggerComment) VALUES (1004, "foobar4", 1, 0, 0, "");
INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (1, 4, 2); INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (1001, 2, 1);
INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (2, 3, 1); INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (1001, 4, 2);
INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (2, 5, 2); INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (1002, 3, 1);
INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (3, 4, 1); INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (1002, 5, 2);
INSERT INTO PackageComaintainers (PackageBaseID, UsersID, Priority) VALUES (1003, 4, 1);
EOD EOD
>sendmail.out && >sendmail.out &&
"$NOTIFY" flag 1 1 && "$NOTIFY" flag 1 1001 &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Out-of-date Notification for foobar Subject: AUR Out-of-date Notification for foobar
To: tu@localhost To: tu@localhost
@ -81,12 +82,13 @@ test_expect_success 'Test subject and body of welcome notifications.' '
test_expect_success 'Test subject and body of comment notifications.' ' test_expect_success 'Test subject and body of comment notifications.' '
cat <<-EOD | sqlite3 aur.db && cat <<-EOD | sqlite3 aur.db &&
INSERT INTO PackageComments (ID, PackageBaseID, UsersID, Comments, RenderedComment) VALUES (1, 1, 1, "This is a test comment.", "This is a test comment."); /* Use package comments IDs which can be distinguished from other IDs. */
INSERT INTO PackageNotifications (PackageBaseID, UserID) VALUES (1, 2); INSERT INTO PackageComments (ID, PackageBaseID, UsersID, Comments, RenderedComment) VALUES (2001, 1001, 1, "This is a test comment.", "This is a test comment.");
INSERT INTO PackageNotifications (PackageBaseID, UserID) VALUES (1001, 2);
UPDATE Users SET CommentNotify = 1 WHERE ID = 2; UPDATE Users SET CommentNotify = 1 WHERE ID = 2;
EOD EOD
>sendmail.out && >sendmail.out &&
"$NOTIFY" comment 1 1 1 && "$NOTIFY" comment 1 1001 2001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Comment for foobar Subject: AUR Comment for foobar
@ -113,7 +115,7 @@ test_expect_success 'Test subject and body of update notifications.' '
UPDATE Users SET UpdateNotify = 1 WHERE ID = 2; UPDATE Users SET UpdateNotify = 1 WHERE ID = 2;
EOD EOD
>sendmail.out && >sendmail.out &&
"$NOTIFY" update 1 1 && "$NOTIFY" update 1 1001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Package Update: foobar Subject: AUR Package Update: foobar
@ -135,7 +137,7 @@ test_expect_success 'Test subject and body of update notifications.' '
test_expect_success 'Test subject and body of out-of-date notifications.' ' test_expect_success 'Test subject and body of out-of-date notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" flag 1 1 && "$NOTIFY" flag 1 1001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Out-of-date Notification for foobar Subject: AUR Out-of-date Notification for foobar
@ -156,7 +158,7 @@ test_expect_success 'Test subject and body of out-of-date notifications.' '
test_expect_success 'Test subject and body of adopt notifications.' ' test_expect_success 'Test subject and body of adopt notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" adopt 1 1 && "$NOTIFY" adopt 1 1001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Ownership Notification for foobar Subject: AUR Ownership Notification for foobar
@ -175,7 +177,7 @@ test_expect_success 'Test subject and body of adopt notifications.' '
test_expect_success 'Test subject and body of co-maintainer addition notifications.' ' test_expect_success 'Test subject and body of co-maintainer addition notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" comaintainer-add 1 1 && "$NOTIFY" comaintainer-add 1 1001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Co-Maintainer Notification for foobar Subject: AUR Co-Maintainer Notification for foobar
@ -193,7 +195,7 @@ test_expect_success 'Test subject and body of co-maintainer addition notificatio
test_expect_success 'Test subject and body of co-maintainer removal notifications.' ' test_expect_success 'Test subject and body of co-maintainer removal notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" comaintainer-remove 1 1 && "$NOTIFY" comaintainer-remove 1 1001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Co-Maintainer Notification for foobar Subject: AUR Co-Maintainer Notification for foobar
@ -211,7 +213,7 @@ test_expect_success 'Test subject and body of co-maintainer removal notification
test_expect_success 'Test subject and body of delete notifications.' ' test_expect_success 'Test subject and body of delete notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" delete 1 1 && "$NOTIFY" delete 1 1001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Package deleted: foobar Subject: AUR Package deleted: foobar
@ -232,7 +234,7 @@ test_expect_success 'Test subject and body of delete notifications.' '
test_expect_success 'Test subject and body of merge notifications.' ' test_expect_success 'Test subject and body of merge notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" delete 1 1 2 && "$NOTIFY" delete 1 1001 1002 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: AUR Package deleted: foobar Subject: AUR Package deleted: foobar
@ -255,13 +257,14 @@ test_expect_success 'Test subject and body of merge notifications.' '
test_expect_success 'Test subject and body of request open notifications.' ' test_expect_success 'Test subject and body of request open notifications.' '
cat <<-EOD | sqlite3 aur.db && cat <<-EOD | sqlite3 aur.db &&
INSERT INTO PackageRequests (ID, PackageBaseID, PackageBaseName, UsersID, ReqTypeID, Comments, ClosureComment) VALUES (1, 1, "foobar", 1, 1, "This is a request test comment.", ""); /* Use package request IDs which can be distinguished from other IDs. */
INSERT INTO PackageRequests (ID, PackageBaseID, PackageBaseName, UsersID, ReqTypeID, Comments, ClosureComment) VALUES (3001, 1001, "foobar", 1, 1, "This is a request test comment.", "");
EOD EOD
>sendmail.out && >sendmail.out &&
"$NOTIFY" request-open 1 1 orphan 1 && "$NOTIFY" request-open 1 3001 orphan 1001 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: [PRQ#1] Orphan Request for foobar Subject: [PRQ#3001] Orphan Request for foobar
EOD EOD
test_cmp actual expected && test_cmp actual expected &&
sed -n "/^\$/,\$p" sendmail.out | base64 -d >actual && sed -n "/^\$/,\$p" sendmail.out | base64 -d >actual &&
@ -279,10 +282,10 @@ test_expect_success 'Test subject and body of request open notifications.' '
test_expect_success 'Test subject and body of request open notifications for merge requests.' ' test_expect_success 'Test subject and body of request open notifications for merge requests.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" request-open 1 1 merge 1 foobar2 && "$NOTIFY" request-open 1 3001 merge 1001 foobar2 &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: [PRQ#1] Merge Request for foobar Subject: [PRQ#3001] Merge Request for foobar
EOD EOD
test_cmp actual expected && test_cmp actual expected &&
sed -n "/^\$/,\$p" sendmail.out | base64 -d >actual && sed -n "/^\$/,\$p" sendmail.out | base64 -d >actual &&
@ -301,16 +304,16 @@ test_expect_success 'Test subject and body of request open notifications for mer
test_expect_success 'Test subject and body of request close notifications.' ' test_expect_success 'Test subject and body of request close notifications.' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" request-close 1 1 accepted && "$NOTIFY" request-close 1 3001 accepted &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: [PRQ#1] Deletion Request for foobar Accepted Subject: [PRQ#3001] Deletion Request for foobar Accepted
EOD EOD
test_cmp actual expected && test_cmp actual expected &&
sed -n "/^\$/,\$p" sendmail.out | base64 -d >actual && sed -n "/^\$/,\$p" sendmail.out | base64 -d >actual &&
echo >>actual && echo >>actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Request #1 has been accepted by user [1]. Request #3001 has been accepted by user [1].
[1] https://aur.archlinux.org/account/user/ [1] https://aur.archlinux.org/account/user/
EOD EOD
@ -319,36 +322,36 @@ test_expect_success 'Test subject and body of request close notifications.' '
test_expect_success 'Test subject and body of request close notifications (auto-accept).' ' test_expect_success 'Test subject and body of request close notifications (auto-accept).' '
>sendmail.out && >sendmail.out &&
"$NOTIFY" request-close 0 1 accepted && "$NOTIFY" request-close 0 3001 accepted &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: [PRQ#1] Deletion Request for foobar Accepted Subject: [PRQ#3001] Deletion Request for foobar Accepted
EOD EOD
test_cmp actual expected && test_cmp actual expected &&
sed -n "/^\$/,\$p" sendmail.out | base64 -d >actual && sed -n "/^\$/,\$p" sendmail.out | base64 -d >actual &&
echo >>actual && echo >>actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Request #1 has been accepted automatically by the Arch User Repository Request #3001 has been accepted automatically by the Arch User
package request system. Repository package request system.
EOD EOD
test_cmp actual expected test_cmp actual expected
' '
test_expect_success 'Test subject and body of request close notifications with closure comment.' ' test_expect_success 'Test subject and body of request close notifications with closure comment.' '
cat <<-EOD | sqlite3 aur.db && cat <<-EOD | sqlite3 aur.db &&
UPDATE PackageRequests SET ClosureComment = "This is a test closure comment." WHERE ID = 1; UPDATE PackageRequests SET ClosureComment = "This is a test closure comment." WHERE ID = 3001;
EOD EOD
>sendmail.out && >sendmail.out &&
"$NOTIFY" request-close 1 1 accepted && "$NOTIFY" request-close 1 3001 accepted &&
grep ^Subject: sendmail.out >actual && grep ^Subject: sendmail.out >actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Subject: [PRQ#1] Deletion Request for foobar Accepted Subject: [PRQ#3001] Deletion Request for foobar Accepted
EOD EOD
test_cmp actual expected && test_cmp actual expected &&
sed -n "/^\$/,\$p" sendmail.out | base64 -d >actual && sed -n "/^\$/,\$p" sendmail.out | base64 -d >actual &&
echo >>actual && echo >>actual &&
cat <<-EOD >expected && cat <<-EOD >expected &&
Request #1 has been accepted by user [1]: Request #3001 has been accepted by user [1]:
This is a test closure comment. This is a test closure comment.