X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=script%2Fmaketestdb.pl;h=db7efbca499d88da8a86ee22ba136fa5e7ad8678;hb=b145d86689af2391a53b9e0ec50526bf680a072d;hp=389b8ec02c507ef87052bac8978835a8e9289c6e;hpb=532cc23bba52829b6205df42f39294949bc5a3db;p=scpubgit%2Fstemmaweb.git diff --git a/script/maketestdb.pl b/script/maketestdb.pl index 389b8ec..db7efbc 100755 --- a/script/maketestdb.pl +++ b/script/maketestdb.pl @@ -9,7 +9,13 @@ use Text::Tradition::Directory; my $DBDIR = 'db'; my $DBNAME = 'traditions.db'; my $DBEXT = 'test'; -# Delete the old directory if it exists +# Make the directory on the filesystem if necessary +unless( -d $DBDIR ) { + mkdir $DBDIR + or die "Could not make database director $DBDIR"; + say "Created directory for test database"; +} +# Delete the old db if it exists if( -f "$DBDIR/$DBNAME.$DBEXT" ) { unlink( "$DBDIR/$DBNAME.$DBEXT" ); } @@ -28,20 +34,28 @@ my $dir = Text::Tradition::Directory->new( extra_args => { create => 1 } ); my $scope = $dir->new_scope(); -say "Created test directory"; +say "Created test database"; # Create users my $user = $dir->add_user({ username => 'user@example.org', password => 'UserPass' }); my $admin = $dir->add_user({ username => 'admin@example.org', password => 'AdminPass', role => 'admin' }); -die "Failed to create test users" unless $user && $admin; +my $openid_user = $dir->create_user({ + url => 'https://www.google.com/accounts/o8/id?id=AItOawlFTlpuHGcI67tqahtw7xOod9VNWffB-Qg', + extensions => {'http://openid.net/srv/ax/1.0' => { 'value.email' =>'openid@example.org' } }, + }); +die "Failed to create test users" unless $user && $admin && $openid_user; say "Created users"; my $t1 = Text::Tradition->new( input => 'Self', file => 't/data/besoin.xml' ); die "Failed to create test tradition #1" unless $t1; $t1->add_stemma( dotfile => 't/data/besoin_stemweb.dot' ); $user->add_tradition( $t1 ); +my $t1b = Text::Tradition->new( input => 'Self', file => 't/data/besoin.xml' ); +$t1b->add_stemma( dotfile => 't/data/besoin_stemweb.dot' ); +$openid_user->add_tradition($t1b); $dir->store( $user ); +$dir->store( $openid_user ); say "Created test user tradition"; my $t2 = Text::Tradition->new( input => 'Tabular', sep_char => ',',