On Thu, 2007-05-17 at 17:29 -0400, Guy Hulbert wrote:
> On Thu, 2007-05-17 at 16:37 -0400, Matt Sergeant wrote:
[snip]
> > I'm thinking this might not be the best situation either... Many
> > times you'll want to test a plugin in isolation...
>
> I have some code for that. It's pretty crappy but I can post what I
> have. I have a working (in production :-) auth_dbi plugin which can
[snip]
> > I think we need a bit more infrastructure for tests - so that each
> > plugin test can have its own config file. Perhaps even something that
> > starts/stops qpsmtpd so we can test the server at the SMTP level as
> > well as these unit tests.
I would call that "acceptance tests". If you have a linux box with an
MTA which delivers only to localhost (Debian does this by default ... I
think other distros are the same) then this seems to be the minimal
config/plugins:
rcpt_ok
queue/smtp-forward localhost
and everything runs. With this you can test everything except queue
plugins.
My idea for this was really so that I could pre-test configuration
changes before dropping them on the production server. But I think it
would do for testing things in isolation.
For developing the plugin code, I set up:
Accept::Qpsmtpd::Plugin
but the 'Accept' is wrong and the namespace confused. It should really
be something like Qpsmtpd::Plugin::Devel. Anyway, I have:
$qp = Accept::Qpsmtpd::Plugin->new();
where $qp has to fake services used by a compiled plugin.
I'll clean this stuff up and post it after the release. Here's what it
looks like:
bld
auth_dbi/
auth_dbi plugin
auth_dbi.t unit test[1]
auth_dbi.run standalone script
db/
Pg.ddl
Pg.load.in load template
domains.txt domains table
passwords.txt passwords table
The script 'bld' converts Pg.load.in to Pg.load by inserting the
contents of the two text files and inserting the db user name in
the right place. You can then:
psql -U USER < Pg.ddl
psql -U USER < Pg.load
to build a test database for the plugin scripts.
You can run auth_dbi.run and it will 'require auth_dbi'. You can
cp auth_dbi $QP/pugins/auth/auth_dbi
cp auth_dbi.t $QP/t/plugin_tests/auth::auth_dbi
and add
auth/auth_dbi DSN
to
config/plugins
and the unit tests run.
I notice that you fixed the plugin tests to use auth/ rather than auth::
so I will need to retest this.
I plan to add mysql.ddl and sqlite.ddl to the db/ directory and the
auth_dbi plugin needs a little work (I dropped CRAM-MD5 and LOGIN from
auth_vpopmail_sql so I need to add those back).
> >
> > All a bit ambitious considering I'm pushing for a release. I'm
> > wondering if we can push some of this issue to the next release?
>
> Definitely. I just wanted to get the unit tests in ... not all the
> other crap.
>
> >
--
--gh