-
Notifications
You must be signed in to change notification settings - Fork 90
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
During the file refactor in #193, an error was made in class names that caused AIX file operations to be severely limited and QNX file support was broken. This restores the AIX and QNX remote file functionality and adds unit tests for each of those classes. Signed-off-by: Adam Leff <adam@leff.co>
- Loading branch information
Showing
6 changed files
with
85 additions
and
8 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
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,26 @@ | ||
require 'helper' | ||
require 'train/transports/local' | ||
require 'train/file/remote/aix' | ||
require 'train/transports/mock' | ||
|
||
describe Train::File::Remote::Aix do | ||
let(:cls) { Train::File::Remote::Aix } | ||
let(:backend) { | ||
backend = Train::Transports::Mock.new.connection | ||
backend.mock_os({ name: 'aix', family: 'unix' }) | ||
backend | ||
} | ||
|
||
it 'returns a nil link_path if the object is not a symlink' do | ||
file = cls.new(backend, 'path') | ||
file.stubs(:symlink?).returns(false) | ||
file.link_path.must_be_nil | ||
end | ||
|
||
it 'returns a correct link_path' do | ||
file = cls.new(backend, 'path') | ||
file.stubs(:symlink?).returns(true) | ||
backend.mock_command("perl -e 'print readlink shift' path", 'our_link_path') | ||
file.link_path.must_equal 'our_link_path' | ||
end | ||
end |
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,44 @@ | ||
require 'helper' | ||
require 'train/transports/local' | ||
require 'train/file/remote/qnx' | ||
require 'train/transports/mock' | ||
|
||
describe Train::File::Remote::Qnx do | ||
let(:cls) { Train::File::Remote::Qnx } | ||
let(:backend) { | ||
backend = Train::Transports::Mock.new.connection | ||
backend.mock_os({ name: 'qnx', family: 'unix' }) | ||
backend | ||
} | ||
|
||
it 'returns file contents when the file exists' do | ||
out = rand.to_s | ||
backend.mock_command('cat path', out) | ||
file = cls.new(backend, 'path') | ||
file.stubs(:exist?).returns(true) | ||
file.content.must_equal out | ||
end | ||
|
||
it 'returns nil contents when the file does not exist' do | ||
file = cls.new(backend, 'path') | ||
file.stubs(:exist?).returns(false) | ||
file.content.must_be_nil | ||
end | ||
|
||
it 'returns a file type' do | ||
backend.mock_command('file path', 'blah directory blah') | ||
cls.new(backend, 'path').type.must_equal :directory | ||
end | ||
|
||
it 'returns a directory type' do | ||
backend.mock_command('file path', 'blah regular file blah') | ||
cls.new(backend, 'path').type.must_equal :file | ||
end | ||
|
||
it 'raises exception for unimplemented methods' do | ||
file = cls.new(backend, 'path') | ||
%w{mode owner group uid gid mtime size selinux_label link_path mounted stat}.each do |m| | ||
proc { file.send(m) }.must_raise NotImplementedError | ||
end | ||
end | ||
end |