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