From 67f73c99dbd655c7ef6b71a0f0721902093ce855 Mon Sep 17 00:00:00 2001 From: Jamis Buck Date: Fri, 12 Aug 2005 21:40:38 +0000 Subject: Subversion module recognizes the password prompt for HTTP authentication git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1997 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- switchtower/test/scm/subversion_test.rb | 118 ++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) create mode 100644 switchtower/test/scm/subversion_test.rb (limited to 'switchtower/test') diff --git a/switchtower/test/scm/subversion_test.rb b/switchtower/test/scm/subversion_test.rb new file mode 100644 index 0000000000..47942d9b9c --- /dev/null +++ b/switchtower/test/scm/subversion_test.rb @@ -0,0 +1,118 @@ +$:.unshift File.dirname(__FILE__) + "/../../lib" + +require 'test/unit' +require 'switchtower/scm/subversion' + +class ScmSubversionTest < Test::Unit::TestCase + class MockLogger + def info(msg,pfx=nil) end + def debug(msg,pfx=nil) end + end + + class MockConfiguration < Hash + def logger + @logger ||= MockLogger.new + end + + def method_missing(sym, *args) + if args.length == 0 + self[sym] + else + super + end + end + end + + class SubversionTest < SwitchTower::SCM::Subversion + attr_accessor :story + attr_reader :last_path + + def svn_log(path) + @last_path = path + story.shift + end + end + + class MockChannel + attr_reader :sent_data + + def send_data(data) + @sent_data ||= [] + @sent_data << data + end + + def [](name) + "value" + end + end + + class MockActor + attr_reader :command + attr_reader :channels + attr_accessor :story + + def initialize(config) + @config = config + end + + def run(command) + @command = command + @channels ||= [] + @channels << MockChannel.new + story.each { |stream, line| yield @channels.last, stream, line } + end + + def method_missing(sym, *args) + @config.send(sym, *args) + end + end + + def setup + @config = MockConfiguration.new + @config[:repository] = "/hello/world" + @config[:svn] = "/path/to/svn" + @config[:password] = "chocolatebrownies" + @scm = SubversionTest.new(@config) + @actor = MockActor.new(@config) + @log_msg = <