Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unify file handling for local and remote transports (#189) #190

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ install:
- ps: winrm create winrm/config/Listener?Address=*+Transport=HTTPS "@{Hostname=`"localhost`";CertificateThumbprint=`"$($env:winrm_cert)`"}"
- ps: $env:PATH="C:\Ruby$env:ruby_version\bin;$env:PATH"
- ps: Write-Host $env:PATH
- ps: Set-Content -Value "hello world" -NoNewLine -Path C:\train_test_file
- ruby --version
- gem --version
- appveyor DownloadFile -Url %bundler_url% -FileName bundler.gem
Expand Down
12 changes: 10 additions & 2 deletions lib/train/transports/local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ def connection(_ = nil)
end

class Connection < BaseConnection
require 'train/transports/local_file'
require 'train/transports/local_os'

def initialize(options)
Expand All @@ -40,7 +39,16 @@ def os
end

def file(path)
@files[path] ||= File.new(self, path)
@files[path] ||= \
if os.aix?
AixFile.new(self, path)
elsif os.solaris?
UnixFile.new(self, path)
elsif os.windows?
WindowsFile.new(self, path)
else
LinuxFile.new(self, path)
end
end

def login_command
Expand Down
90 changes: 0 additions & 90 deletions lib/train/transports/local_file.rb

This file was deleted.

184 changes: 0 additions & 184 deletions test/unit/transports/local_file_test.rb

This file was deleted.

68 changes: 68 additions & 0 deletions test/windows/local_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,74 @@
cmd.stderr.must_equal ''
end

describe 'verify file' do
let(:file) { conn.file('C:\\train_test_file') }

it 'exists' do
file.exist?.must_equal(true)
end

it 'is a file' do
file.file?.must_equal(true)
end

it 'has type :file' do
file.type.must_equal(:file)
end

it 'has content' do
# TODO: this shouldn't include newlines that aren't in the original file
file.content.must_equal("hello world\r\n\r\n")
end

it 'has owner name' do
file.owner.wont_be_nil
end

it 'has no group name' do
file.group.must_be_nil
end

it 'has no mode' do
file.mode.must_be_nil
end

it 'has an md5sum' do
file.md5sum.wont_be_nil
end

it 'has an sha256sum' do
file.sha256sum.wont_be_nil
end

it 'has no modified time' do
file.mtime.must_be_nil
end

it 'has no size' do
# TODO: this really ought to be implemented
file.size.must_be_nil
end

it 'has no selinux label handling' do
file.selinux_label.must_be_nil
end

it 'has product_version' do
file.product_version.wont_be_nil
end

it 'has file_version' do
file.file_version.wont_be_nil
end

it 'provides a json representation' do
j = file.to_json
j.must_be_kind_of Hash
j['type'].must_equal :file
end
end

after do
# close the connection
conn.close
Expand Down
Loading