Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
When executing multiline commands, escape newlines with a backslash
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1975 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
- Loading branch information
Showing
5 changed files
with
96 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
*SVN* | ||
|
||
* When executing multiline commands, use a backslash to escape the newline |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
$:.unshift File.dirname(__FILE__) + "/../lib" | ||
|
||
require 'stringio' | ||
require 'test/unit' | ||
require 'switchtower/command' | ||
|
||
class CommandTest < Test::Unit::TestCase | ||
class MockSession | ||
def open_channel | ||
{ :closed => true, :status => 0 } | ||
end | ||
end | ||
|
||
class MockActor | ||
attr_reader :sessions | ||
|
||
def initialize | ||
@sessions = Hash.new { |h,k| h[k] = MockSession.new } | ||
end | ||
end | ||
|
||
def setup | ||
@actor = MockActor.new | ||
end | ||
|
||
def test_command_executes_on_all_servers | ||
command = SwitchTower::Command.new(%w(server1 server2 server3), | ||
"hello", nil, {}, @actor) | ||
assert_equal %w(server1 server2 server3), @actor.sessions.keys.sort | ||
end | ||
|
||
def test_command_with_newlines | ||
command = SwitchTower::Command.new(%w(server1), "hello\nworld", nil, {}, | ||
@actor) | ||
assert_equal "hello\\\nworld", command.command | ||
end | ||
|
||
def test_command_with_windows_newlines | ||
command = SwitchTower::Command.new(%w(server1), "hello\r\nworld", nil, {}, | ||
@actor) | ||
assert_equal "hello\\\nworld", command.command | ||
end | ||
end |