The Great Re-write of 2010: CGI::Session/Test::Database/DBIx::NamedDSN
I have just finished a re-write of CGI::Session, called Data::Session, and started wondering how best to test it.
I've always disliked setting all the env vars to make its tests work for MySQL, PG, etc, so I hit CPAN looking for A Better Way.
I found Test::Database, which seemed to be a good idea. But examining the code was discouraging, so I decided to re-write that too.
I soon realized that one thing (among many - see below) which bugged me about Test::Database was its handing of DSNs.
So I decided to split that out into a separate distro, using an INI-style file, so I could add extra attributes to the DSN, such as active and use_for_testing. I might add use_for_production too.
That's why I've just released to CPAN DBIx::Admin::DSNManager V 1.00.
Now I'll use that in the re-write of Test::Database, which I'm going to call Test::Admin::Database.
I don't want to reuse the namespace Test::Database, since the aims of the modules are a bit different.
Then finally the latter can be used to help test Data::Session which I'll release as V 0.90 at first.
Pain with Test::Database:
1) Test::Database does not install with cpanm. First you have to install DBD::CSV V 0.31 twice. Then it installs.
2) Also, the docs for Test::Database are very hard to fillow. For instance, under Description,
it talks about install leading you through configuration, and writing ~/.test-database. That does not happen. Perhaps it did once upon a time.
3) Also, in Test::Database::Tutorial, there is a talk about the difference between a dsn and a driver_dsn, but the code does not follow the docs.
For example, when I used a dsn (in ~/.test-database) for Postgres, with a user who has createdb rights, that dsn is ignored. But if I use dsn_driver, it is used.
4) Also, if I put a dsn for SQLite in ~/.test-databas, to see what happens, I get 2 handles to SQLite. Perhaps that's a good idea, but it should be documented.
5) Also, Test::Database does not use File::HomeDir - it should.
6) Also, when I remove dsns from ~/.test-database, the module does not rewrite /tmp/Test-Database-ron//Pg/mapping.yml, which is then left with dsns I don't want to use.