From e1d4b3dd098d2107bbf5ca84d36c8052706e86a8 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Mon, 7 Oct 2013 14:03:19 -0400 Subject: [PATCH] Add some fixture code. --- test/rm_account_test.rb | 2 ++ test/sql/agendav-fixtures.sql | 4 +++ test/sql/davical-fixtures.sql | 8 ++++++ test/sql/postfixadmin-fixtures.sql | 44 ++++++++++++++++++++++++++++++ test/sql/roundcube-fixtures.sql | 3 ++ 5 files changed, 61 insertions(+) create mode 100644 test/sql/agendav-fixtures.sql create mode 100644 test/sql/davical-fixtures.sql create mode 100644 test/sql/postfixadmin-fixtures.sql create mode 100644 test/sql/roundcube-fixtures.sql diff --git a/test/rm_account_test.rb b/test/rm_account_test.rb index b2d6174..e39ead5 100644 --- a/test/rm_account_test.rb +++ b/test/rm_account_test.rb @@ -58,6 +58,8 @@ class RmAccountTest < Test::Unit::TestCase sql = File.open("test/sql/#{plugin}.sql").read() plugin_conn.query(sql) + sql = File.open("test/sql/#{plugin}-fixtures.sql").read() + plugin_conn.query(sql) plugin_conn.close() end diff --git a/test/sql/agendav-fixtures.sql b/test/sql/agendav-fixtures.sql new file mode 100644 index 0000000..76cdba1 --- /dev/null +++ b/test/sql/agendav-fixtures.sql @@ -0,0 +1,4 @@ +/* Add an AgenDAV record for one user only. */ +INSERT INTO prefs (username, options) VALUES ('adam@example.net', 'herp'); +INSERT INTO shared (user_from, user_which, calendar) + VALUES ('adam@example.net', 'beth@example.net', 'derp'); diff --git a/test/sql/davical-fixtures.sql b/test/sql/davical-fixtures.sql new file mode 100644 index 0000000..775fa6b --- /dev/null +++ b/test/sql/davical-fixtures.sql @@ -0,0 +1,8 @@ +/* Add a DAViCal record for one user. */ +INSERT INTO usr (user_no, username) VALUES (17, 'alice@example.com'); + +/* Create a settings record for that user -- these should be linked + * via a foreign key. + */ +INSERT INTO usr_setting (user_no, setting_name, setting_value) + VALUES (17, 'dumb setting', 'its dumb value'); diff --git a/test/sql/postfixadmin-fixtures.sql b/test/sql/postfixadmin-fixtures.sql new file mode 100644 index 0000000..2ca6d59 --- /dev/null +++ b/test/sql/postfixadmin-fixtures.sql @@ -0,0 +1,44 @@ +/* This is a magic record, always included as the first row of the + * domain table. + */ +INSERT INTO domain (domain) VALUES ('ALL'); + +/* Create two domains, example.com, and example.net. */ +INSERT INTO domain (domain) VALUES ('example.com'); +INSERT INTO domain (domain) VALUES ('example.net'); + +/* + * Now create their mailboxes, two in one domain, and three in the + * other. + */ +INSERT INTO mailbox (username, domain, local_part) + VALUES ('alice@example.com', 'example.com', 'alice'); +INSERT INTO mailbox (username, domain, local_part) + VALUES ('bob@example.com', 'example.com', 'bob'); + +INSERT INTO mailbox (username, domain, local_part) + VALUES ('adam@example.net', 'example.net', 'adam'); +INSERT INTO mailbox (username, domain, local_part) + VALUES ('beth@example.net', 'example.net', 'beth'); +INSERT INTO mailbox (username, domain, local_part) + VALUES ('carol@example.net', 'example.net', 'carol'); + +/* Each mailbox has an alias pointing to (at least) itself. */ +INSERT INTO alias (address, goto, domain) + VALUES ('alice@example.com', 'alice@example.com', 'example.com'); +INSERT INTO alias (address, goto, domain) + VALUES ('bob@example.com', 'bob@example.com', 'example.com'); + +INSERT INTO alias (address, goto, domain) + VALUES ('adam@example.net', 'adam@example.net', 'example.net'); +INSERT INTO alias (address, goto, domain) + VALUES ('beth@example.net', 'beth@example.net', 'example.net'); +INSERT INTO alias (address, goto, domain) + VALUES ('carol@example.net', 'carol@example.net', 'example.net'); + +/* Create a domain admin for both example.com and example.net. */ +INSERT INTO domain_admins (username, domain) + VALUES ('admin@example.com', 'example.com'); +INSERT INTO domain_admins (username, domain) + VALUES ('admin@example.com', 'example.net'); + diff --git a/test/sql/roundcube-fixtures.sql b/test/sql/roundcube-fixtures.sql new file mode 100644 index 0000000..6dc10cb --- /dev/null +++ b/test/sql/roundcube-fixtures.sql @@ -0,0 +1,3 @@ +/* Create records for a subset of the five example.com/net users */ +INSERT INTO users (username) VALUES ('alice@example.com'); +INSERT INTO users (username) VALUES ('adam@example.net') -- 2.44.2