]>
gitweb.michael.orlitzky.com - mailshears.git/blob - test/rm_account_test.rb
4 require 'common/configuration'
6 class RmAccountTest
< Test
::Unit::TestCase
8 TESTCONF_PATH
= 'test/mailshears.test.conf.yml'
10 def connect_superuser()
19 connection
= PGconn
.connect(db_host
,
32 cfg
= Configuration
.new(TESTCONF_PATH
)
33 argv = ["adam@example.net"]
35 # Load each of the plugins that we'll need.
36 cfg
.plugins
.each
do |plugin_file
|
37 require "rm/plugins/#{plugin_file}"
41 require "rm/rm_runner"
42 require "rm/rm_dummy_runner"
45 output_buffer
= StringIO
.new()
47 $stdout = output_buffer
48 plugin_class
= RmPlugin
.run(cfg
, *argv)
51 actual
= output_buffer
.string()
53 expected
= "PostfixadminRm - Removed user: " +
54 "adam@example.net (adam@example.net)\n" +
55 "RoundcubeRm - Removed user: adam@example.net (User ID: 2)\n" +
56 "AgendavRm - Removed user: adam@example.net " +
57 "(Username: adam@example.net)\n" +
58 "DavicalRm - User not found: adam@example.net\n"
59 assert(actual
== expected
)
63 # Create databases using from the test configuration file.
64 cfg
= Configuration
.new(TESTCONF_PATH
)
65 connection
= connect_superuser()
67 cfg
.plugins
.each
do |plugin
|
68 plugin_dbname
= cfg
.send("#{plugin}_dbname")
69 query
= "CREATE DATABASE #{plugin_dbname};"
70 connection
.query(query
)
72 plugin_dbhost
= cfg
.send("#{plugin}_dbhost")
73 plugin_dbport
= cfg
.send("#{plugin}_dbport")
74 plugin_dbopts
= cfg
.send("#{plugin}_dbopts")
75 plugin_dbtty
= cfg
.send("#{plugin}_dbtty")
76 plugin_dbuser
= cfg
.send("#{plugin}_dbuser")
77 plugin_dbpass
= cfg
.send("#{plugin}_dbpass")
79 plugin_conn
= PGconn
.connect(plugin_dbhost
,
87 sql
= File
.open("test/sql/#{plugin}.sql").read()
88 plugin_conn
.query(sql
)
89 sql
= File
.open("test/sql/#{plugin}-fixtures.sql").read()
90 plugin_conn
.query(sql
)
99 # Destroy databases using from the test configuration file.
100 cfg
= Configuration
.new(TESTCONF_PATH
)
101 connection
= connect_superuser()
103 cfg
.plugins
.each
do |plugin
|
104 plugin_dbname
= cfg
.send("#{plugin}_dbname")
105 query
= "DROP DATABASE #{plugin_dbname};"
106 connection
.query(query
)