Commits

Anonymous committed e74bc52

Got the tests to have a perfect coverage (except for the pods). Added
the COPYING file to the repository (it was missing earlier.)

  • Participants
  • Parent commits b5eaa2c

Comments (0)

Files changed (4)

+This is the MIT/X11 license:
+
+--------------
+Copyright 2004 Shlomi Fish.
+
+Permission is hereby granted, free of charge, to any person obtaining
+a copy of this software and associated documentation files (the
+"Software"), to deal in the Software without restriction, including
+without limitation the rights to use, copy, modify, merge, publish,
+distribute, sublicense, and/or sell copies of the Software, and to
+permit persons to whom the Software is furnished to do so, subject to
+the following conditions:
+
+The above copyright notice and this permission notice shall be
+included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+OTHER DEALINGS IN THE SOFTWARE.
+

lib/SVN/RaWeb/Light.pm

     {
         return $self->process_dir();
     }
-    elsif ($node_kind eq $SVN::Node::file)
+    # This means $node_kind eq $SVN::Node::file
+    else
     {
         return $self->process_file();
     }
 use warnings;
 use strict;
 
-use Test::More tests => 31;
+use Test::More tests => 33;
 
 # We need to load the mocking modules first because they fill the 
 # namespaces and %INC. Otherwise, "use CGI" and "use SVN::*" will cause
     );
 }
 
+
+{
+    local @CGI::new_params = ('path_info' => "/trunk/invalid");
+
+    local @SVN::Ra::new_params =
+    (
+        'check_path' => sub {
+            my ($self, $path, $rev_num) = @_;
+            if ($path eq "trunk/invalid")
+            {
+                return $SVN::Node::unknown;
+            }
+            die "Wrong path queried - $path.";
+        },
+    );
+    reset_out_buffer();
+
+    my $svn_ra_web =
+        SVN::RaWeb::Light->new(
+            'url' => "http://svn-i.shlomifish.org/svn/myrepos/"
+        );
+
+    eval {
+    $svn_ra_web->run();
+    };
+
+    # TEST
+    ok(!$@, "Testing that no exception was thrown.");
+    
+    my $results = get_out_buffer();
+
+    # TEST
+    is($results, ("Content-Type: text/html\n\n" . 
+        "<html><head><title>Does not exist!</title></head>" . 
+        "<body><h1>Does not exist!</h1></body></html>"),
+        "Checking for correct results for unknown file"
+    );
+}
+
 # Test the directory output for a regular (non-root) directory.
 {
     local @CGI::new_params = ('path_info' => "/trunk/mydir/");
+#!/usr/bin/perl
+
+use warnings;
+use strict;
+
+use Test::More tests => 3;
+
+# We need to load the mocking modules first because they fill the 
+# namespaces and %INC. Otherwise, "use CGI" and "use SVN::*" will cause
+# the real modules to be loaded.
+use SVN::RaWeb::Light::Mock::CGI;
+use SVN::RaWeb::Light::Mock::Svn;
+use SVN::RaWeb::Light::Mock::Stdout;
+
+use SVN::RaWeb::Light;
+
+package SVN::RaWeb::Light::ThrowHash;
+
+use base 'SVN::RaWeb::Light';
+
+# Throw a hash reference without a 'callback' parameter.
+sub real_run
+{
+    die +{ 'one' => "two", 'shlomi' => "fish", };
+}
+
+package SVN::RaWeb::Light::ThrowArray;
+
+use base 'SVN::RaWeb::Light';
+
+# Throw a hash reference without a 'callback' parameter.
+sub real_run
+{
+    die [ "eenie", "meenie", "mynie", "mow"];
+}
+
+package SVN::RaWeb::Light::ThrowString;
+
+use base 'SVN::RaWeb::Light';
+
+# Throw a hash reference without a 'callback' parameter.
+sub real_run
+{
+    die "Hallelujah - an exception was thrown";
+}
+
+package main;
+
+{
+    my $obj = SVN::RaWeb::Light::ThrowHash->new(
+        'url' => "http://svn-i.shlomifish.org/svn/myrepos/"
+    );
+    eval
+    {
+        $obj->run();
+    };
+    # TEST
+    is_deeply($@, +{ 'one' => "two", 'shlomi' => "fish", }, 
+        "Checking that hash thrown without a callback key is thrown further."
+    );
+}
+
+{
+    my $obj = SVN::RaWeb::Light::ThrowArray->new(
+        'url' => "http://svn-i.shlomifish.org/svn/myrepos/"
+    );
+    eval
+    {
+        $obj->run();
+    };
+    # TEST
+    is_deeply($@, [ "eenie", "meenie", "mynie", "mow"],
+        "Checking that hash thrown without a callback key is thrown further."
+    );
+}
+
+{
+    my $obj = SVN::RaWeb::Light::ThrowString->new(
+        'url' => "http://svn-i.shlomifish.org/svn/myrepos/"
+    );
+    eval
+    {
+        $obj->run();
+    };
+    # TEST
+    like($@, qr{^Hallelujah},
+        "Checking that a string thrown is thrown further."
+    );
+}
+