source: ProjectBuilder/devel/pb-modules/t/Base.t@ 1147

Last change on this file since 1147 was 1147, checked in by Bruno Cornec, 13 years ago
  • A inimal version of Test::More is required to perform test (especially on older version). Now fixed
File size: 1.7 KB
Line 
1#!/usr/bin/perl -w
2#
3# Tests ProjectBuilder::Base functions
4
5use strict;
6use ProjectBuilder::Base;
7
8eval
9{
10 require Test::More;
11 Test::More->import();
12 my ($tmv,$tmsv) = split(/\./,$Test::More::VERSION);
13 if ($tmsv lt 87) {
14 die "Test::More is not available in an appropriate version ($tmsv)";
15 }
16};
17
18# Test::More appropriate version not found so no test will be performed here
19if ($@) {
20 require Test;
21 plan(tests => 1);
22 print "# Faking tests as Test::More is not available in an appropriate version\n";
23 ok(1,1);
24 exit(0);
25}
26
27my $nt = 0;
28my $test = {
29 # Full URI
30 "svn+ssh://account\@machine.sdom.tld:8080/path/to/file" => ["svn+ssh","account","machine.sdom.tld","8080","/path/to/file"],
31 # Partial URI
32 "http://machine2/path1/to/anotherfile" => ["http","","machine2","","/path1/to/anotherfile"],
33 };
34
35my ($scheme, $account, $host, $port, $path);
36foreach my $uri (keys %$test) {
37 ($scheme, $account, $host, $port, $path) = pb_get_uri($uri);
38
39 is($scheme, $test->{$uri}[0], "pb_get_uri Test protocol $uri");
40 $nt++;
41
42 is($account, $test->{$uri}[1], "pb_get_uri Test account $uri");
43 $nt++;
44
45 is($host, $test->{$uri}[2], "pb_get_uri Test host $uri");
46 $nt++;
47
48 is($port, $test->{$uri}[3], "pb_get_uri Test port $uri");
49 $nt++;
50
51 is($path, $test->{$uri}[4], "pb_get_uri Test path $uri");
52 $nt++;
53}
54
55$ENV{'TMPDIR'} = "/tmp";
56pb_temp_init();
57like($ENV{'PBTMP'}, qr|/tmp/pb\.[0-9A-z]+|, "pb_temp_init Test");
58$nt++;
59
60my $content = "This is content with TABs and spaces and \ncarriage returns\n";
61open(FILE,"> $ENV{'PBTMP'}/test") || die "Unable to create temp file";
62print FILE $content;
63close(FILE);
64
65my $cnt = pb_get_content("$ENV{'PBTMP'}/test");
66is($cnt, $content, "pb_get_content Test");
67$nt++;
68
69done_testing($nt);
Note: See TracBrowser for help on using the repository browser.