$:.unshift File.join(File.dirname(__FILE__), "..", "..", "lib") require 'test/unit' require 'buildmaster' module BuildMaster class CvsClientTest < Test::Unit::TestCase protected def setUp() super end private def ensure_folder_exists(path) if (not File.exists? path) Dir.mkdir(path) end end public def test_load_CvsInfo folder = 'tmp' ensure_folder_exists(folder); root = ':ext:wolfdancer@cvsserver.com:/cvs/root' repository = 'xpe' write("#{folder}/ROOT", root) write("#{folder}/Repository", repository) cvs = CvsInfo.load(folder) assert_equal(root, cvs.root) assert_equal(repository, cvs.repository) end def tes_checkout log = '' client = CvsClient.new(CvsInfo.new('root', 'module'), 'working') {|command| log = command} client.checkout assert_equal('cvs -d root co -d working module', log) end def test_update log = '' client = CvsClient.new(CvsInfo.new('root', 'module'), 'working') {|command| log = command} client.update assert_equal('cvs -d root update working', log) client.update('-PAd') assert_equal('cvs -d root update -PAd working', log) end def test_command log = '' client = CvsClient.new(CvsInfo.new('root', 'module'), 'working') {|command| log = command} client.command('command -option argument') assert_equal('cvs -d root command -option argument working', log) end private def write(fileName, content) File.open(fileName, "w") do |file| file.puts content end end end end