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