X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=script%2Fmaketestdb.pl;h=a662274f430ac5cf044c9b8b839b4be4780ac00d;hb=0a326d3fc5d71491b8c62336bc89db0835b2f29b;hp=021f528cd49ba9b2b209aa3454042b1736aa8113;hpb=56e3972ee78693b5fbcb530fad920ed9beb6be5a;p=scpubgit%2Fstemmaweb.git diff --git a/script/maketestdb.pl b/script/maketestdb.pl index 021f528..a662274 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,7 +34,7 @@ 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' }); @@ -39,6 +45,7 @@ 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 ); $dir->store( $user ); say "Created test user tradition"; @@ -53,5 +60,11 @@ my $t3 = Text::Tradition->new( input => 'Self', file => 't/data/john.xml' ); $t3->public( 1 ); $t3->name( 'John verse' ); $dir->store( $t3 ); +my $t4 = Text::Tradition->new( input => 'Self', file => 't/data/collatecorr.xml' ); +$t4->public( 1 ); +$user->add_tradition( $t4 ); +$dir->store( $t4 ); +$dir->store( $user ); + say "Created test public traditions";