mirror of
https://github.com/capistrano/capistrano
synced 2023-03-27 23:21:18 -04:00
472431004c
git-svn-id: http://svn.rubyonrails.org/rails/tools/capistrano@6288 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
38 lines
No EOL
1.5 KiB
Ruby
38 lines
No EOL
1.5 KiB
Ruby
require "#{File.dirname(__FILE__)}/../../utils"
|
|
require 'capistrano/configuration/actions/file_transfer'
|
|
|
|
class ConfigurationActionsFileTransferTest < Test::Unit::TestCase
|
|
class MockConfig
|
|
include Capistrano::Configuration::Actions::FileTransfer
|
|
end
|
|
|
|
def setup
|
|
@config = MockConfig.new
|
|
@config.stubs(:logger).returns(stub_everything)
|
|
end
|
|
|
|
def test_put_should_pass_options_to_execute_on_servers
|
|
@config.expects(:execute_on_servers).with(:foo => "bar")
|
|
@config.put("some data", "test.txt", :foo => "bar")
|
|
end
|
|
|
|
def test_put_should_delegate_to_Upload_process
|
|
@config.expects(:execute_on_servers).yields(%w(s1 s2 s3).map { |s| mock(:host => s) })
|
|
@config.expects(:sessions).times(3).returns(Hash.new{|h,k| h[k] = k.to_sym})
|
|
Capistrano::Upload.expects(:process).with([:s1,:s2,:s3], "test.txt", :data => "some data", :mode => 0777, :logger => @config.logger)
|
|
@config.put("some data", "test.txt", :mode => 0777)
|
|
end
|
|
|
|
def test_get_should_pass_options_execute_on_servers_including_once
|
|
@config.expects(:execute_on_servers).with(:foo => "bar", :once => true)
|
|
@config.get("test.txt", "test.txt", :foo => "bar")
|
|
end
|
|
|
|
def test_get_should_use_sftp_get_file_to_local_path
|
|
sftp = mock("sftp", :state => :closed, :connect => true)
|
|
sftp.expects(:get_file).with("remote.txt", "local.txt")
|
|
@config.expects(:execute_on_servers).yields([stub("server", :host => "capistrano")])
|
|
@config.expects(:sessions).returns("capistrano" => mock("session", :sftp => sftp))
|
|
@config.get("remote.txt", "local.txt")
|
|
end
|
|
end |