Alien-SVN

 view release on metacpan or  search on metacpan

src/subversion/subversion/bindings/swig/perl/native/t/3client.t  view on Meta::CPAN

# "License"); you may not use this file except in compliance
# with the License.  You may obtain a copy of the License at
#
#   http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied.  See the License for the
# specific language governing permissions and limitations
# under the License.
#
#

use Test::More tests => 297;
use strict;

# shut up about variables that are only used once.
# these come from constants and variables used
# by the bindings but not elsewhere in perl space.
no warnings 'once';

# TEST
use_ok('SVN::Core');
# TEST
use_ok('SVN::Repos');
# TEST
use_ok('SVN::Client');
# TEST
use_ok('SVN::Wc'); # needed for status
use File::Spec::Functions;
use File::Temp qw(tempdir);
use File::Path qw(rmtree);

# do not use cleanup because it will fail, some files we
# will not have write perms to.
my $testpath = tempdir('svn-perl-test-XXXXXX', TMPDIR => 1, CLEANUP => 0);

my $repospath = catdir($testpath,'repo');
my $reposurl = 'file://' . (substr($repospath,0,1) ne '/' ? '/' : '')
               . $repospath;
my $wcpath = catdir($testpath,'wc');
my $importpath = catdir($testpath,'import');

# Use internal style paths on Windows
$reposurl =~ s/\\/\//g;
$wcpath =~ s/\\/\//g;
$importpath =~ s/\\/\//g;

# track current rev ourselves to test against
my $current_rev = 0;

# We want to trap errors ourself
$SVN::Error::handler = undef;

# Get username we are running as
my $username;
if ($^O eq 'MSWin32') {
    $username = getlogin();
} else {
    $username = getpwuid($>) || getlogin();
}

# This is ugly to create the test repo with SVN::Repos, but
# it seems to be the most reliable way.
# TEST
ok(SVN::Repos::create("$repospath", undef, undef, undef, undef),
   "create repository at $repospath");

my ($ctx) = SVN::Client->new;
# TEST
isa_ok($ctx,'SVN::Client','Client Object');

my $uuid_from_url = $ctx->uuid_from_url($reposurl);
# TEST
ok($uuid_from_url,'Valid return from uuid_from_url method form');

# test non method invocation passing a SVN::Client
# TEST
ok(SVN::Client::uuid_from_url($reposurl,$ctx),
   'Valid return from uuid_from_url function form with SVN::Client object');

# test non method invocation passing a _p_svn_client_ctx_t
# TEST
ok(SVN::Client::uuid_from_url($reposurl,$ctx->{'ctx'}),
   'Valid return from uuid_from_url function form with _p_svn_client_ctx object');


my ($ci_dir1) = $ctx->mkdir(["$reposurl/dir1"]);
# TEST
isa_ok($ci_dir1,'_p_svn_client_commit_info_t');
$current_rev++;
# TEST
is($ci_dir1->revision,$current_rev,"commit info revision equals $current_rev");

my ($ci_dir2) = $ctx->mkdir2(["$reposurl/dir2"]);
# TEST
isa_ok($ci_dir2,'_p_svn_commit_info_t');
$current_rev++;
# TEST
is($ci_dir2->revision,$current_rev,"commit info revision equals $current_rev");

my ($ci_dir3) = $ctx->mkdir3(["$reposurl/dir3"],0,undef);
# TEST
isa_ok($ci_dir3,'_p_svn_commit_info_t');
$current_rev++;
# TEST
is($ci_dir3->revision,$current_rev,"commit info revision equals $current_rev");

# TEST
is($ctx->mkdir4(["$reposurl/dir4"],0,undef,sub {
      my ($commit_info) = @_;

      # TEST
      isa_ok($commit_info,'_p_svn_commit_info_t','commit_info type check');

      # TEST
      is($commit_info->revision(),$current_rev + 1, 'commit info revision');

      # TEST
      like($commit_info->date(),



( run in 0.556 second using v1.01-cache-2.11-cpan-97f6503c9c8 )