The last few days I've been hacking together some more tests and indeed
have now read our entire suite of tests. While I was doing this I noticed
that we seem to have several ways of doing things so it might be worth
deciding on the best.
Firstly the clean up of node.db between tests. We currently have 3 if not
4 ways of doing this.
foreach my $del_node ( $wiki->list_all_nodes ) {
print "# Deleting node $del_node\n";
$wiki->delete_node( $del_node ) or die "Can't delete $del_node";
}
which doesnt clear indexes.
Wiki::Toolkit::Setup::SQLite::cleardb( { dbname => "t/node.db" } );
which also doesnt clean indexes
unlink "t/node.db";
unlink <t/indexes/*>;
Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
which is the most useful.
then in one test that becomes a sub
sub refresh_db {
unlink "t/node.db";
unlink <t/indexes/*>;
Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
}
and then used several times.
Repeatitive code pains me. Therefore I feel we should make refresh_db a
sub in OpenGuides::Test and then use that. I have a patch for that and
will also probably go through and clean up all the tests.
Secondly, We have 3 ways to do node generation. All of which are fine but
we should probably pick one and run with it. This would take more time to
change in the test suite. Also there maybe reasons in a test why one way
is used above another.
The first way is
OpenGuides::Test->write_data(
node => "Wombats",
guide => $guide,
username => "bob",
edit_type => "Minor tidying",
return_output => 1,
);
which IHMO should be the prefered method.
the second method seem to be along ther lines of
my $q = CGI->new;
$q->param( -name => "content", -value => "foo" );
$q->param( -name => "categories", -value => "" );
$q->param( -name => "locales", -value => "" );
$q->param( -name => "phone", -value => "" );
$q->param( -name => "fax", -value => "" );
$q->param( -name => "website", -value => "" );
$q->param( -name => "hours_text", -value => "" );
$q->param( -name => "address", -value => "" );
$q->param( -name => "postcode", -value => "" );
$q->param( -name => "map_link", -value => "" );
$q->param( -name => "os_x", -value => "" );
$q->param( -name => "os_y", -value => "" );
$q->param( -name => "username", -value => "bob" );
$q->param( -name => "comment", -value => "foo" );
$q->param( -name => "edit_type", -value => "Minor tidying" );
$ENV{REMOTE_ADDR} = "127.0.0.1";
my $output = $guide->commit_node(
return_output => 1,
id => "Wombats",
cgi_obj => $q,
);
the third method is
$wiki->write_node( "British Museum", "Huge museum, lots of artifacts.",
undef,
{ category => ["Museums", "Major Attractions"]
, locale => ["Holborn", "Bloomsbury"] } );
Another thing we need to look at is config generation.
we should probably just be using
my $config = OpenGuides::Test->make_basic_config;
then changing anything we want with lines like.
$config->script_name( "wiki.cgi" );
$config->script_url( "http://example.com/" );
instead of
my $config = OpenGuides::Config->new(
vars => {
dbtype => "sqlite",
dbname => "t/node.db",
indexing_directory => "t/indexes",
script_name => "wiki.cgi",
script_url => "http://example.com/",
site_name => "Test Site",
template_path => "./templates",
home_name => "Home",
use_plucene => 1
}
);
its possibly worth extending the basic config in Openguides::Test.
Finally a couple of the test files have useful subroutines in them whch
should probably be put into Openguides::Test.
So thoughts, questions or indeed comments?
--
bob walker
buses should be purple and bendy
No I think we'll have to look a bit closer than that. I'll try and get a
chance to look at it. Looks pretty simple and will be easy with a browser to
test against. I'll get back to you with some code.
Apologies for top posting but watching Le Tour on the couch.
--
Simon Rumble <simon(a)rumble.net>
On Jul 22, 2009 10:43 PM, "David Cantrell" <david(a)cantrell.org.uk> wrote:
On Wed, Jul 22, 2009 at 10:08:31AM +1000, Simon Rumble wrote: > Got myself a
little more informed n...
Yay, lets make up our own standard! Thanks google!
> And it looks like someone has already done the legwork to make it work
both > ways: > http://ajax...
I added a <script src=geometa.js></script> to my version, see if that
works for you now.
--
David Cantrell | Minister for Arbitrary Justice
"There's a hole in my bucket, dear Liza, dear Liza."
"WHAT MAKES YOU SAY THERE IS A HOLE IN YOUR BUCKET?"
-- OpenGuides-Dev mailing list - OpenGuides-Dev(a)lists.openguides.org
http://lists.openguides.org/ma...