require 'rubygems' require 'fileutils' require 'net/http' require 'net/https' require 'net/scp' require 'uri' require 'rexml/document' require 'log4r' require 'tmpdir' require_relative '../lib/depengine/provider/repository' require_relative '../lib/depengine/log/log' $log = Log::DeploymentLogger.new $log.writer.level = Log4r::DEBUG describe 'getting a file' do context 'with maven' do it 'should get from a remote repository' do tmp_dir = Dir.mktmpdir begin test = Provider::Repository.new test.repository = 'http://repo1.maven.org/maven2/' test.user = '' test.password = '' test.method = 'maven' test.get_from_repository('org/apache/maven/maven-model/2.2.1/maven-model-2.2.1.jar', tmp_dir) File.file?(tmp_dir + '/maven-model-2.2.1.jar').should be true ensure FileUtils.remove_entry tmp_dir end end end context 'with SCP' do it 'should get a file from a remote host' do tmp_dir = Dir.mktmpdir begin FileUtils.mkdir tmp_dir + '/source' FileUtils.touch tmp_dir + '/source/test.file' test = Provider::Repository.new test.host = 'localhost' test.user = ENV['USER'] test.sshkey = ENV['HOME'] + '/.ssh/id_rsa' test.method = 'scp' test.get_from_repository(tmp_dir + '/source/test.file', tmp_dir) File.file?(tmp_dir + '/test.file').should be true ensure FileUtils.remove_entry tmp_dir end end end # context "with SVN" do # it "should do a checkout" do # tmp_dir = Dir.mktmpdir # begin # test = Provider::Repository.new() # test.repository = "file://#{tmp_dir}" # test.user = "" # test.password = "" # test.method = "svn" # test.svncmd = "checkout" # test.svnbinary = "/usr/bin/svn" # FileUtils.rm_rf(tmp_dir+'/deploy_engine') # test.get_from_repository("S2B_Projekte/DTE/deploy_engine/lib/depengine/provider", tmp_dir+"/deploy_engine/lib/depengine/provider") # File.file?(tmp_dir+'/deploy_engine/lib/depengine/provider/repository.rb').should be true # ensure # FileUtils.remove_entry tmp_dir # end # end # it "should do export on a directory" do # tmp_dir = Dir.mktmpdir # begin # test = Provider::Repository.new() # test.repository = "http://svn" # test.user = "" # test.password = "" # test.method = "svn" # test.svncmd = "export" # test.svnbinary = "/usr/bin/svn" # FileUtils.rm_rf(tmp_dir+'/deploy_engine') # test.get_from_repository("S2B_Projekte/DTE/deploy_engine/lib/depengine/provider", tmp_dir+"/deploy_engine/lib/depengine/provider") # File.file?(tmp_dir+'/deploy_engine/lib/depengine/provider/repository.rb').should be true # ensure # FileUtils.remove_entry tmp_dir # end # end # it "should do a export on a singly file" do # tmp_dir = Dir.mktmpdir # begin # test = Provider::Repository.new() # test.repository = "http://svn" # test.user = "" # test.password = "" # test.method = "svn" # test.svncmd = "export" # test.svnbinary = "/usr/bin/svn" # FileUtils.rm_rf(tmp_dir+'/deploy_engine') # test.get_from_repository("S2B_Projekte/DTE/deploy_engine/lib/depengine/provider/repository.rb", tmp_dir+"/deploy_engine/lib/depengine/provider") # File.file?(tmp_dir+'/deploy_engine/lib/depengine/provider/repository.rb').should be true # ensure # FileUtils.remove_entry tmp_dir # end # end # end end