From 35cf00e636a90c04adaef8375b323a13771d59c1 Mon Sep 17 00:00:00 2001 From: Ted Wang Date: Wed, 23 Aug 2017 11:46:23 -0500 Subject: [PATCH] Local transport on Windows should use WindowsFile (#189) --- appveyor.yml | 1 + test/windows/local_test.rb | 71 ++++++++++++++++++++++++++++++++++++++ test/windows/winrm_test.rb | 71 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 143 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index 433fcfc8..71a430e6 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -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: echo hello world > "C:\train_test_file" - ruby --version - gem --version - appveyor DownloadFile -Url %bundler_url% -FileName bundler.gem diff --git a/test/windows/local_test.rb b/test/windows/local_test.rb index 30c903e4..36d00c81 100644 --- a/test/windows/local_test.rb +++ b/test/windows/local_test.rb @@ -39,6 +39,77 @@ cmd.stderr.must_equal '' end + describe 'verify file' do + let(:file) { backend.file('C:\\train_test_file') } + + it 'is an instance of WindowsFile' do + file.must_be_instance_of(Train::Extras::WindowsFile) + end + + 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 + file.content.must_equal('hello world') + end + + it 'has no owner name' do + file.owner.must_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 diff --git a/test/windows/winrm_test.rb b/test/windows/winrm_test.rb index 37140b37..e8487ab5 100644 --- a/test/windows/winrm_test.rb +++ b/test/windows/winrm_test.rb @@ -45,6 +45,77 @@ cmd.stderr.must_equal '' end + describe 'verify file' do + let(:file) { backend.file('C:\\train_test_file') } + + it 'is an instance of WindowsFile' do + file.must_be_instance_of(Train::Extras::WindowsFile) + end + + 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 + file.content.must_equal('hello world') + end + + it 'has no owner name' do + file.owner.must_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