1 ### make sure we can find our conf.pl file
4 require "$FindBin::Bin/inc/conf.pl";
10 use Test::More eval { load 'CPANPLUS::Internals::Source::SQLite'; 1 }
12 : (skip_all => "SQLite engine not available");
15 use File::Basename qw[dirname];
17 use CPANPLUS::Backend;
18 use CPANPLUS::Internals::Constants;
20 my $conf = gimme_conf();
22 ### make sure we use the SQLite engine
23 $conf->set_conf( source_engine => 'CPANPLUS::Internals::Source::SQLite' );
25 my $cb = CPANPLUS::Backend->new( $conf );
26 my $mod = TEST_CONF_MODULE;
27 my $auth = TEST_CONF_AUTHOR;
29 ok( $cb->reload_indices( update_source => 1 ),
31 ok( $cb->__sqlite_dbh, " Got a DBH " );
32 ok( $cb->__sqlite_file, " Got a DB file" );
35 ### make sure we have trees and they're hashes
36 { ok( $cb->author_tree, "Got author tree" );
37 isa_ok( $cb->author_tree, "HASH" );
39 ok( $cb->module_tree, "Got module tree" );
40 isa_ok( $cb->module_tree, "HASH" );
43 ### save state, shouldn't work
44 { CPANPLUS::Error->flush;
45 my $rv = $cb->save_state;
47 ok( !$rv, "Saving state not implemented" );
48 like( CPANPLUS::Error->stack_as_string, qr/not implemented/i,
49 " Diagnostics confirmed" );
54 $auth => 'author_tree',
55 $mod => 'module_tree',
58 while( my($str, $meth) = each %map ) {
60 ok( $str, "Trying to retrieve $str" );
61 ok( $cb->$meth( $str ), " Got $str object via ->$meth" );
62 ok( $cb->$meth->{$str}, " Got author object via ->{ $str }" );
63 ok( exists $cb->$meth->{ $str },
64 " Testing exists() " );
65 ok( not(exists( $cb->$meth->{ $$ } )),
66 " And non-exists() " );
67 cmp_ok( scalar(keys(%{ $cb->$meth })), ">", 1,
70 cmp_ok( scalar(keys(%{ $cb->$meth })), '==', scalar(keys(%{ $cb->$meth })),
73 while( my($key,$val) = each %{ $cb->$meth } ) {
74 ok( $key, " Retrieved $key via each()" );
75 ok( $val, " And value" );
76 ok( ref $val, " Value is a ref: $val" );
77 can_ok( $val, '_id' );