Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Return proper error code when unable to convert a relative path to an…
… absolute path. Suggested by Yogesh Sharma.
- Loading branch information
Showing
5 changed files
with
129 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#################################################################################################################################### | ||
# ArchiveUnitTest.pm - Tests for ArchiveCommon module | ||
#################################################################################################################################### | ||
package pgBackRestTest::Archive::ArchiveUnitTest; | ||
use parent 'pgBackRestTest::Full::FullCommonTest'; | ||
|
||
#################################################################################################################################### | ||
# Perl includes | ||
#################################################################################################################################### | ||
use strict; | ||
use warnings FATAL => qw(all); | ||
use Carp qw(confess); | ||
|
||
use File::Basename qw(dirname); | ||
|
||
use pgBackRest::ArchiveCommon; | ||
use pgBackRest::Common::Exception; | ||
use pgBackRest::Common::Log; | ||
use pgBackRest::Config::Config; | ||
|
||
#################################################################################################################################### | ||
# run | ||
#################################################################################################################################### | ||
sub run | ||
{ | ||
my $self = shift; | ||
|
||
# Increment the run, log, and decide whether this unit test should be run | ||
if (!$self->begin('unit')) {return} | ||
|
||
# Unit tests for walPath() | ||
#----------------------------------------------------------------------------------------------------------------------- | ||
{ | ||
my $strDbPath = '/db'; | ||
my $strWalFileRelative = 'pg_xlog/000000010000000100000001'; | ||
my $strWalFileAbsolute = "${strDbPath}/${strWalFileRelative}"; | ||
|
||
# Error is thrown if the wal file is relative and there is no db path | ||
$self->testException( | ||
sub {walPath($strWalFileRelative, undef, CMD_ARCHIVE_GET)}, ERROR_OPTION_REQUIRED, | ||
"option '" . OPTION_DB_PATH . "' must be specified when relative xlog paths are used\n" . | ||
"HINT: Is \%f passed to " . CMD_ARCHIVE_GET . " instead of \%p?\n" . | ||
"HINT: PostgreSQL may pass relative paths even with \%p depending on the environment."); | ||
|
||
# Relative path is contructed | ||
$self->testResult(sub {walPath($strWalFileRelative, $strDbPath, CMD_ARCHIVE_PUSH)}, $strWalFileAbsolute); | ||
|
||
# Path is not relative and db-path is still specified | ||
$self->testResult(sub {walPath($strWalFileAbsolute, $strDbPath, CMD_ARCHIVE_PUSH)}, $strWalFileAbsolute); | ||
|
||
# Path is not relative and db-path is undef | ||
$self->testResult(sub {walPath($strWalFileAbsolute, $strDbPath, CMD_ARCHIVE_PUSH)}, $strWalFileAbsolute); | ||
} | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters