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