EchoForum/db/tests.sql

64 lines
2.4 KiB
SQL

-- CANT HAVE SAME USERNAME
INSERT INTO doki8902.user(username, password) VALUES ('Frank', 'admin123');
-- CANT HAVE INVALID USERNAME
INSERT INTO doki8902.user(username, password) VALUES ('Frank@', 'admin123');
INSERT INTO doki8902.user(username, password) VALUES ('1', 'admin123');
INSERT INTO doki8902.user(username, password) VALUES ('ABCDEABCDE1234512345ABCDEABCDE1234512345', 'admin123');
-- CANT HAVE REPEATING CATEGORIES
INSERT INTO doki8902.post_category(name) VALUES ('Technology');
-- CANT POST WITH INVALID AUTHOR
INSERT INTO message_post(author_id, category_id, name, latest_content) VALUES
(100, 1, 'Best practices for data security', 'It''s crucial to keep your software updated to avoid security breaches.');
-- CANT POST FOR NON EXISTENT CATEGORY
INSERT INTO message_post(author_id, category_id, name, latest_content) VALUES
(2, 100, 'Best practices for data security', 'It''s crucial to keep your software updated to avoid security breaches.');
-- CANT COMMENT WITH INVALID AUTHOR
INSERT INTO message_comment(author_id, post_id, latest_content, parent_comment_id) VALUES
(100, 1, 'Absolutely! Regular updates are a must.', NULL);
-- CANT COMMENT FOR INVALID POST
INSERT INTO message_comment(author_id, post_id, latest_content, parent_comment_id) VALUES
(1, 100, 'Absolutely! Regular updates are a must.', NULL);
-- CANT VOTE TWICE
INSERT INTO doki8902.message_vote(message_id, user_id, vote) VALUES
(1, 4, 1);
-- CANT VOTE NOT SUPPORTED VALUES
INSERT INTO doki8902.message_vote(message_id, user_id, vote) VALUES
(1, 5, 5);
-- CANT VOTE WITH INVALID IDS
INSERT INTO doki8902.message_vote(message_id, user_id, vote) VALUES (100, 5, 1);
INSERT INTO doki8902.message_vote(message_id, user_id, vote) VALUES (1, 100, 1);
-- CANT REPLY TO COMMENT THAT DOES NOT EXISTS IN POST
INSERT INTO doki8902.message_comment(author_id, post_id, latest_content, parent_comment_id) VALUES
(11, 3, 'test', 20);
-- CANT POST EMPTY MESSAGES
INSERT INTO message_post(author_id, category_id, name, latest_content) VALUES (2, 1, '', 'Content');
INSERT INTO message_post(author_id, category_id, name, latest_content) VALUES (2, 1, 'Name', '');
INSERT INTO doki8902.message_comment(author_id, post_id, latest_content, parent_comment_id) VALUES (11, 1, '', NULL);
-- CANT POST WITHOUT AN EXISTING USER
INSERT INTO message_post(author_id, category_id, name, latest_content) VALUES (NULL, 1, 'Name', 'Content');