Bugzilla – Attachment 151877 Details for
Bug 33870
Remove T::D::C from Sitemapper.t
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33870: Fix indentation in subtest
Bug-33870-Fix-indentation-in-subtest.patch (text/plain), 8.33 KB, created by
Marcel de Rooy
on 2023-05-31 13:18:19 UTC
(
hide
)
Description:
Bug 33870: Fix indentation in subtest
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-05-31 13:18:19 UTC
Size:
8.33 KB
patch
obsolete
>From 52f1bac17548fb4f9e659d219db9e13625c469d8 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Wed, 31 May 2023 12:12:34 +0000 >Subject: [PATCH] Bug 33870: Fix indentation in subtest >Content-Type: text/plain; charset=utf-8 > >Test plan: >git diff -w HEAD~1.. t/db_dependent/Sitemapper.t > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > t/db_dependent/Sitemapper.t | 198 ++++++++++++++++++------------------ > 1 file changed, 99 insertions(+), 99 deletions(-) > >diff --git a/t/db_dependent/Sitemapper.t b/t/db_dependent/Sitemapper.t >index d1b36f1f72..f62c71fbe1 100755 >--- a/t/db_dependent/Sitemapper.t >+++ b/t/db_dependent/Sitemapper.t >@@ -42,33 +42,33 @@ $schema->storage->txn_begin; > subtest 'Sitemapper' => sub { > plan tests => 12; > >-my $now = dt_from_string()->ymd; >- >-# FIXME Would be nice to remove both deletes again >-Koha::Checkouts->delete; >-Koha::Biblios->delete; >-my $biblio1 = $builder->build_sample_biblio; >-$biblio1->set({ datecreated => '2013-11-15', timestamp => '2013-11-15' })->store; >-my $id1 = $biblio1->id; >-my $biblio2 = $builder->build_sample_biblio; >-$biblio2->set({ datecreated => '2015-08-31', timestamp => '2015-08-31' })->store; >-my $id2 = $biblio2->id; >- >-my $dir = C4::Context::temporary_directory; >- >-# Create a sitemap for a catalog containg 2 biblios, with option 'long url' >-my $sitemapper = Koha::Sitemapper->new( >- verbose => 0, >- url => 'http://www.mylibrary.org', >- dir => $dir, >- short => 0, >-); >-$sitemapper->run(); >- >-my $file = "$dir/sitemapindex.xml"; >-ok( -e "$dir/sitemapindex.xml", 'File sitemapindex.xml created' ); >-my $file_content = read_file($file); >-my $expected_content = <<"EOS"; >+ my $now = dt_from_string()->ymd; >+ >+ # FIXME Would be nice to remove both deletes again >+ Koha::Checkouts->delete; >+ Koha::Biblios->delete; >+ my $biblio1 = $builder->build_sample_biblio; >+ $biblio1->set({ datecreated => '2013-11-15', timestamp => '2013-11-15' })->store; >+ my $id1 = $biblio1->id; >+ my $biblio2 = $builder->build_sample_biblio; >+ $biblio2->set({ datecreated => '2015-08-31', timestamp => '2015-08-31' })->store; >+ my $id2 = $biblio2->id; >+ >+ my $dir = C4::Context::temporary_directory; >+ >+ # Create a sitemap for a catalog containg 2 biblios, with option 'long url' >+ my $sitemapper = Koha::Sitemapper->new( >+ verbose => 0, >+ url => 'http://www.mylibrary.org', >+ dir => $dir, >+ short => 0, >+ ); >+ $sitemapper->run(); >+ >+ my $file = "$dir/sitemapindex.xml"; >+ ok( -e "$dir/sitemapindex.xml", 'File sitemapindex.xml created' ); >+ my $file_content = read_file($file); >+ my $expected_content = <<"EOS"; > <?xml version="1.0" encoding="UTF-8"?> > > <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> >@@ -78,13 +78,13 @@ my $expected_content = <<"EOS"; > </sitemap> > </sitemapindex> > EOS >-chop $expected_content; >-is( $file_content, $expected_content, 'Its content is valid' ); >+ chop $expected_content; >+ is( $file_content, $expected_content, 'Its content is valid' ); > >-$file = "$dir/sitemap0001.xml"; >-ok( -e $file, 'File sitemap0001.xml created' ); >-$file_content = read_file($file); >-$expected_content = <<"EOS"; >+ $file = "$dir/sitemap0001.xml"; >+ ok( -e $file, 'File sitemap0001.xml created' ); >+ $file_content = read_file($file); >+ $expected_content = <<"EOS"; > <?xml version="1.0" encoding="UTF-8"?> > > <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> >@@ -98,22 +98,22 @@ $expected_content = <<"EOS"; > </url> > </urlset> > EOS >-is( $file_content, $expected_content, 'Its content is valid' ); >- >-# Create a sitemap for a catalog containg 2 biblios, with option 'short url'. >-# Test that 2 files are created. >-$sitemapper = Koha::Sitemapper->new( >- verbose => 0, >- url => 'http://www.mylibrary.org', >- dir => $dir, >- short => 1, >-); >-$sitemapper->run(); >- >-$file = "$dir/sitemap0001.xml"; >-ok( -e $file, 'File sitemap0001.xml with short URLs created' ); >-$file_content = read_file($file); >-$expected_content = <<"EOS"; >+ is( $file_content, $expected_content, 'Its content is valid' ); >+ >+ # Create a sitemap for a catalog containg 2 biblios, with option 'short url'. >+ # Test that 2 files are created. >+ $sitemapper = Koha::Sitemapper->new( >+ verbose => 0, >+ url => 'http://www.mylibrary.org', >+ dir => $dir, >+ short => 1, >+ ); >+ $sitemapper->run(); >+ >+ $file = "$dir/sitemap0001.xml"; >+ ok( -e $file, 'File sitemap0001.xml with short URLs created' ); >+ $file_content = read_file($file); >+ $expected_content = <<"EOS"; > <?xml version="1.0" encoding="UTF-8"?> > > <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> >@@ -127,27 +127,27 @@ $expected_content = <<"EOS"; > </url> > </urlset> > EOS >-is( $file_content, $expected_content, 'Its content is valid' ); >- >-# No need to create 75000 biblios here. Let's create 10 with $MAX == 6. >-# Expecting 3 files: index plus 2 url files with 6 and 4 urls. >-$Koha::Sitemapper::Writer::MAX = 6; >-for my $count ( 3..10 ) { >- my $biblio2 = $builder->build_sample_biblio->set({ datecreated => '2015-08-31', timestamp => '2015-08-31' })->store; >-} >- >-$sitemapper = Koha::Sitemapper->new( >- verbose => 0, >- url => 'http://www.mylibrary.org', >- dir => $dir, >- short => 1, >-); >-$sitemapper->run(); >- >-$file = "$dir/sitemapindex.xml"; >-ok( -e "$dir/sitemapindex.xml", 'File sitemapindex.xml for 10 bibs created' ); >-$file_content = read_file($file); >-$expected_content = <<"EOS"; >+ is( $file_content, $expected_content, 'Its content is valid' ); >+ >+ # No need to create 75000 biblios here. Let's create 10 with $MAX == 6. >+ # Expecting 3 files: index plus 2 url files with 6 and 4 urls. >+ $Koha::Sitemapper::Writer::MAX = 6; >+ for my $count ( 3..10 ) { >+ my $biblio2 = $builder->build_sample_biblio->set({ datecreated => '2015-08-31', timestamp => '2015-08-31' })->store; >+ } >+ >+ $sitemapper = Koha::Sitemapper->new( >+ verbose => 0, >+ url => 'http://www.mylibrary.org', >+ dir => $dir, >+ short => 1, >+ ); >+ $sitemapper->run(); >+ >+ $file = "$dir/sitemapindex.xml"; >+ ok( -e "$dir/sitemapindex.xml", 'File sitemapindex.xml for 10 bibs created' ); >+ $file_content = read_file($file); >+ $expected_content = <<"EOS"; > <?xml version="1.0" encoding="UTF-8"?> > > <sitemapindex xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> >@@ -161,34 +161,34 @@ $expected_content = <<"EOS"; > </sitemap> > </sitemapindex> > EOS >-chop $expected_content; >-is( $file_content, $expected_content, 'Its content is valid' ); >- >-$file = "$dir/sitemap0001.xml"; >-ok( -e $file, 'File sitemap0001.xml created' ); >- >-open my $fh, '<', $file or croak; >-my $count = 0; >-while (<$fh>) { >- if ( $_ =~ /<loc>/xsm ) { $count++; } >-} >-close $fh; >-is( $count, 6, 'It contains 6 URLs' ); >- >-$file = "$dir/sitemap0002.xml"; >-ok( -e $file, 'File sitemap0002.xml created' ); >- >-open $fh, '<', $file or croak; >-$count = 0; >-while (<$fh>) { >- if ( $_ =~ /<loc>/xsm ) { $count++; } >-} >-close $fh; >-is( $count, 4, 'It contains 4 URLs' ); >- >-# Cleanup >-for my $file (qw/sitemapindex.xml sitemap0001.xml sitemap0002.xml/) { >- unlink "$dir/$file"; >-} >+ chop $expected_content; >+ is( $file_content, $expected_content, 'Its content is valid' ); >+ >+ $file = "$dir/sitemap0001.xml"; >+ ok( -e $file, 'File sitemap0001.xml created' ); >+ >+ open my $fh, '<', $file or croak; >+ my $count = 0; >+ while (<$fh>) { >+ if ( $_ =~ /<loc>/xsm ) { $count++; } >+ } >+ close $fh; >+ is( $count, 6, 'It contains 6 URLs' ); >+ >+ $file = "$dir/sitemap0002.xml"; >+ ok( -e $file, 'File sitemap0002.xml created' ); >+ >+ open $fh, '<', $file or croak; >+ $count = 0; >+ while (<$fh>) { >+ if ( $_ =~ /<loc>/xsm ) { $count++; } >+ } >+ close $fh; >+ is( $count, 4, 'It contains 4 URLs' ); >+ >+ # Cleanup >+ for my $file (qw/sitemapindex.xml sitemap0001.xml sitemap0002.xml/) { >+ unlink "$dir/$file"; >+ } > }; > $schema->storage->txn_rollback; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 33870
:
151875
|
151876
|
151877
|
153453
|
153454
|
153455
|
155094
|
155095
|
155096