SVN-Notify

 view release on metacpan or  search on metacpan

t/htmlcolordiff.t  view on Meta::CPAN

like( $email, qr{Content-Type: text/html; charset=UTF-8\n},
      'Check HTML file Content-Type' );
like( $email, qr{Content-Transfer-Encoding: 8bit\n},
      'Check HTML file Content-Transfer-Encoding');

##############################################################################
# Try viewcvs_url + HTML.
##############################################################################
ok( $notifier = SVN::Notify::HTML::ColorDiff->new(
    %args,
     viewcvs_url => 'http://svn.example.com/?rev=%s&view=rev',
),
    "Construct new HTML viewcvs_url notifier" );
isa_ok($notifier, 'SVN::Notify::HTML::ColorDiff');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Prepare HTML viewcvs_url" );
ok( $notifier->execute, "Notify HTML viewcvs_url" );

# Check the output.
$email = get_output();
like( $email,
      qr|<dt>Revision</dt>\s+<dd><a href="http://svn\.example\.com/\?rev=111\&amp;view=rev">111</a></dd>\n|,
      'Check for HTML URL');

##############################################################################
# Try svnweb_url + HTML.
##############################################################################
ok( $notifier = SVN::Notify::HTML::ColorDiff->new(
    %args,
     svnweb_url => 'http://svn.example.com/?rev=%s&view=rev',
), "Construct new HTML svnweb_url notifier" );
isa_ok($notifier, 'SVN::Notify::HTML::ColorDiff');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Prepare HTML svnweb_url" );
ok( $notifier->execute, "Notify HTML svnweb_url" );

# Check the output.
$email = get_output();
like( $email,
      qr|<dt>Revision</dt>\s+<dd><a href="http://svn\.example\.com/\?rev=111\&amp;view=rev">111</a></dd>\n|,
      'Check for HTML URL');

##############################################################################
# Try encoding.
##############################################################################
ok( $notifier = SVN::Notify::HTML::ColorDiff->new(
    %args,
    encoding => 'ISO-8859-1'
), "Construct new encoding notifier" );
isa_ok($notifier, 'SVN::Notify::HTML::ColorDiff');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Prepare encoding" );
ok( $notifier->execute, "Notify encoding" );

# Check the output.
$email = get_output();
like( $email, qr{Content-Type: text/html; charset=ISO-8859-1\n},
      'Check Content-Type charset' );

##############################################################################
# Try html format with propsets.
##############################################################################
ok( $notifier = SVN::Notify::HTML::ColorDiff->new(%args, with_diff => 1,
                                                  revision => '333'),
    "Construct new propset notifier" );
isa_ok($notifier, 'SVN::Notify::HTML::ColorDiff');
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Prepare propset HTML file" );
ok( $notifier->execute, "Notify propset HTML file" );

# Check the output.
$email = get_output();
like( $email, qr{Subject: \[333\] Property modification\.\n},
      "Check subject header for propset HTML" );
like( $email, qr/From: theory\n/, 'Check propset HTML From');
like( $email, qr/To: test\@example\.com\n/, 'Check propset HTML To');
like( $email, qr{Content-Type: text/html; charset=UTF-8\n},
      'Check propset HTML Content-Type' );
like( $email, qr{Content-Transfer-Encoding: 8bit\n},
      'Check propset HTML Content-Transfer-Encoding');

# Check for a header for the modified file.
like( $email, qr{<a id="trunkactivitymailbinactivitymail"></a>\n},
      "Check for modified file div ID");
like( $email, qr{<div class="modfile"><h4>Modified: trunk/activitymail/bin/activitymail \(681 => 682\)</h4>},
      "Check for modified file header" );

# Check for propset file.
like( $email, qr{<a id="trunkactivitymailbinactivitymail"></a>\n},
      "Check for modified file div ID");
like( $email, qr{<div class="propset"><h4>Property changes: trunk/activitymail/t/activitymail\.t</h4>},
      "Check for modified file header" );

##############################################################################
# SVNWeb URL.
##############################################################################
ok( $notifier = SVN::Notify::HTML::ColorDiff->new(
    %args,
    revision     => 444,
    svnweb_url   => 'http://svn.example.com/index.cgi/revision/?rev=%s',
),
    "Construct new complext notifier" );
isa_ok($notifier, 'SVN::Notify::HTML');
isa_ok($notifier, 'SVN::Notify');
ok( $notifier->prepare, "Prepare complex example" );
ok( $notifier->execute, "Notify complex example" );

$email = get_output();

# Make sure multiple lines are still multiple!
like($email, qr/link\.\n\nWe/, "Check for multiple lines" );

# Check for SVNWeb URLs.
like( $email,
      qr|<dt>Revision</dt>\s+<dd><a href="http://svn\.example\.com/index\.cgi/revision/\?rev=444">444</a></dd>\n|,
      'Check for main SVNWeb URL');
like($email,
     qr{<a href="http://svn\.example\.com/index\.cgi/revision/\?rev=6000">Revision 6000</a>\.},
     "Check for first log mesage SVNWeb URL");
like($email,
     qr{<a href="http://svn\.example\.com/index\.cgi/revision/\?rev=6001">rev\n6001</a>\.},
     "Check for split line log mesage SVNWeb URL");
unlike($email,
       qr{<a href="http://svn\.example\.com/index\.cgi/revision/\?rev=200">rev 200</a>,},
       "Check for no rev 200 SVNWeb URL");

##############################################################################
# Try max_diff_length
#############################################################################
ok $notifier = SVN::Notify::HTML::ColorDiff->new(
    %args,
    max_diff_length => 512,
    with_diff       => 1,
), 'Construct new max_diff_length notifier';

isa_ok $notifier, 'SVN::Notify';
isa_ok $notifier, 'SVN::Notify::HTML';
is $notifier->max_diff_length, 512, 'max_diff_hlength should be set';
ok $notifier->with_diff, 'with_diff should be set';
ok $notifier->prepare, 'Prepare max_diff_length checking';
ok $notifier->execute, 'Notify max_diff_length checking';

# Check the output.
$email = get_output();
like $email, qr{Use Apache::RequestRec for mod_perl 2},
    'Check for the last diff line';
unlike $email, qr{ BEGIN }, 'Check for missing extra line';
like $email, qr{Diff output truncated at 512 characters.},
    'Check for truncation message';

##############################################################################



( run in 0.559 second using v1.01-cache-2.11-cpan-71847e10f99 )