X-Git-Url: http://git.indexdata.com/?a=blobdiff_plain;f=perl%2Ft%2F07_sort.t;h=4081dff827d027106660c3e0adc31a32a87e0d08;hb=4cea1b9769079a2cdc143f4fe483e69d5b77a813;hp=11f985b86c5cab97a90fc733e88f1bc5a0f5262e;hpb=8e1d114f1969b19d12afc6ab0b04031e35ae5c88;p=idzebra-moved-to-github.git diff --git a/perl/t/07_sort.t b/perl/t/07_sort.t index 11f985b..4081dff 100644 --- a/perl/t/07_sort.t +++ b/perl/t/07_sort.t @@ -1,6 +1,6 @@ #!perl # ============================================================================= -# $Id: 07_sort.t,v 1.1 2003-03-03 18:27:25 pop Exp $ +# $Id: 07_sort.t,v 1.4 2004-09-16 15:07:55 heikki Exp $ # # Perl API header # ============================================================================= @@ -14,13 +14,15 @@ BEGIN { use strict; use warnings; -use Test::More tests => 14; +use Test::More tests => 32; # ---------------------------------------------------------------------------- # Session opening and closing BEGIN { use IDZebra; - IDZebra::logFile("test.log"); + unlink("test07.log"); + IDZebra::logFile("test07.log"); +# IDZebra::logLevel(0x4F); # IDZebra::logLevel(15); use_ok('IDZebra::Session'); use_ok('pod'); @@ -32,7 +34,28 @@ BEGIN { my $sess = IDZebra::Session->open(configFile => 'demo/zebra.cfg', groupName => 'demo2'); # ---------------------------------------------------------------------------- -# search +# Insert some test data +my $ret; +my $sysno; +my $F; +my $filecount=0; +$sess->init; +$sess->begin_trans; +$sess->databases('demo1', 'demo2'); +$ret=$sess->end_trans; + +$sess->begin_trans; +for $F () +{ + ($ret,$sysno)=$sess->insert_record (file=>$F, recordType => 'grs.perl.pod'); + ok( $ret==0, "inserted $F"); + #print STDERR "Inserted $F ok. ret=$ret sys=$sysno\n"; + $filecount++; +} +$ret=$sess->end_trans; +ok($filecount>0,"Inserted files"); +is($ret->{inserted},$filecount, "Inserted all"); + # ----------------------------------------------------------------------------- # Search 1 database, retrieve records, sort "titles" locally (dangerous!) @@ -83,6 +106,8 @@ ok (($sortError == 0), "sorting ascending"); # ----------------------------------------------------------------------------- # Sort descending, new rs +#TODO: { +# todo_skip "Sort into different rset crashes", 3; my $rs2 = $rs1->sort('1=4 id'); @@ -90,15 +115,18 @@ isa_ok ($rs2, 'IDZebra::Resultset'); $wasError = 0; $sortError = 0; -foreach my $rec ($rs1->records()) { +foreach my $rec ($rs2->records()) { if ($rec->{errCode}) { $wasError++; } my ($title) = ($rec->buf =~ /\n\s*package\s+([a-zA-Z0-9:]+)\s*\;\s*\n/); - if ($sortedi[$rs2->count - $rec->position] ne $title) { $sortError++; } + if ($sorted[$rs2->count - $rec->position] ne $title) { $sortError++; } + is ($title, $sorted[$rs2->count - $rec->position], "sort order $title"); } -ok (($wasError == 0), "retrieval"); -ok (($sortError == 0), "sorting descending"); +is ($wasError,0 , "retrieval"); +is ($sortError, 0, "sorting descending"); + +# } # end of SKIP # ----------------------------------------------------------------------------- # Search + sort ascending