Skip to content

Commit

Permalink
fix os for mock tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-rock committed Dec 29, 2015
1 parent 1e6a9b4 commit 1c41a57
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/unit/transports/local_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@
require 'helper'
require 'train/transports/local'

# overwrite os detection to simplify mock tests, otherwise run_command tries to
# determine the OS first and fails the tests
class Train::Transports::Local::Connection
class OS < OSCommon
def initialize(backend)
super(backend, { family: 'train_mock_os' })
end

def detect_family
# no op, we do not need to detect the os
end
end
end

describe 'local transport' do
let(:transport) { Train::Transports::Local.new }
let(:connection) { transport.connection }
Expand Down
14 changes: 14 additions & 0 deletions test/unit/transports/ssh_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
require 'helper'
require 'train/transports/ssh'

# overwrite os detection to simplify mock tests, otherwise run_command tries to
# determine the OS first and fails the tests
class Train::Transports::SSH::Connection
class OS < OSCommon
def initialize(backend)
super(backend, { family: 'train_mock_os' })
end

def detect_family
# no op, we do not need to detect the os
end
end
end

describe 'ssh transport' do
let(:cls) { Train::Transports::SSH }
let(:conf) {{
Expand Down

0 comments on commit 1c41a57

Please sign in to comment.