Sha256: 0c300b41c47875d89b7418e56707bf38395d9c1db08ffb45fb9f5a8c4cef279b
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
require 'helper' require 'oas/log_collector/source' module MySSHSession def exec!(command, &block) _exec("/tmp/fileone.txt\n/tmp/filetwo.txt", :stdout, &block) end def close; end private def _exec(data, stream = :stdout, &block) if block_given? block.call true, stream, data else return data end end end module MySSHSessionWithError include MySSHSession def exec!(command, &block) _exec("something was wrong", :stderr, &block) end end class TestSource < MiniTest::Unit::TestCase def setup @source = OAS::LogCollector::Source.new('remote-host.com', 'user') end def test_find_with_error session = Class.new { include MySSHSessionWithError } Net::SSH.stub :start, session.new do assert_raises OAS::LogCollector::Source::Error do @source.find("/tmp") end end end def test_find_successful session = Class.new { include MySSHSession } Net::SSH.stub :start, session.new do result = @source.find("/tmp") assert_instance_of Array, result assert_equal 2, result.size end end def test_find_command_builder session = Minitest::Mock.new session.expect :exec!, "", ["find /tmp -type 'f' -name '*.txt'"] session.expect :close, nil Net::SSH.stub :start, session do result = @source.find("/tmp", { :type => 'f', :name => '*.txt' }) end session.verify end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
oas-log-collector-0.1.6 | test/test_source.rb |
oas-log-collector-0.1.5 | test/test_source.rb |
oas-log-collector-0.1.4 | test/test_source.rb |