[harness + basic test for albumhtml
ganesh@earth.li**20040415084430] {
move ./test/handlers.pl ./test/harness.pl
hunk ./test/harness.pl 46
+use PhotoPub::Album qw(&albumhtml);
hunk ./test/harness.pl 151
+ } elsif($command eq 'albumhtml') {
+ &testalbumhtml(args => $data->{'args'},data => $data->{'script'});
hunk ./test/harness.pl 269
+sub compareblock {
+ my ($errortext,$gotarr,$expectedarr)=@_;
+ my $got;
+ my $expected;
+ do {
+ $got=shift @$gotarr;
+ $expected=shift @$expectedarr;
+ } while(defined $got && defined $expected && $expected eq $got);
+
+ return unless defined $got || defined $expected;
+
+ print $errortext."\n";
+ print " Expected:\n";
+ while(defined $expected) {
+ print " $expected";
+ $expected=shift @$expectedarr;
+ }
+ print " Got:\n";
+ while(defined $got) {
+ print " $got";
+ $got=shift @$gotarr;
+ }
+}
+
hunk ./test/harness.pl 309
- my $got;
- my $expected;
- do {
- $got=shift @got;
- $expected=shift @expected;
- } while(defined $got && defined $expected && $expected eq $got);
hunk ./test/harness.pl 310
- return unless defined $got || defined $expected;
-
- print "Mismatch reading album $album$posinfo\n";
- print " Expected:\n";
- while(defined $expected) {
- print " $expected";
- $expected=shift @expected;
- }
- print " Got:\n";
- while(defined $got) {
- print " $got";
- $got=shift @got;
- }
+ &compareblock("Mismatch reading album $album$posinfo",\@got,\@expected);
hunk ./test/harness.pl 331
+sub testalbumhtml {
+ my (%options)=@_;
+ my $args=$options{'args'};
+ my @expected=@{&gettext($options{'data'})};
+ my %args=split(/(?:\=|\s+)/,$options{'args'});
+
+ my $got="";
+ &albumhtml(\%args,sub {},sub { $got.=shift; });
+ my @got=();
+ foreach my $line (split(/\n/,$got)) {
+ next if $line eq '';
+ push @got,"$line\n";
+ }
+ &compareblock("Mismatch in HTML for $args",\@got,\@expected);
+}
+
addfile ./test/test13
hunk ./test/test13 1
-
+# Album HTML
+::run test ! -d scratch
+::run mkdir scratch
+
+::sleep 1
+:{write scratch/photopubrc
+
+ dir scratch
+ suffix .jpg
+
+
+ dir scratch
+ filename info
+ makealbum all
+
+
+ standard scratch/album.thtml
+
+:}
+
+:{write scratch/info
+group 1-5 foo
+:}
+
+:{write scratch/album.thtml
+
+
+$description
+
+
+:}
+
+:{init
+:{albumhtml album=/all style=/standard
+foo
+:}
+:}
+
+::run rm scratch/*
+::run rmdir scratch
}