From 5662bb7383386ca5f445ac7cfb4eda264b047ffa Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Mon, 5 Oct 2015 23:46:33 +0200 Subject: [PATCH] migrate transport runner tests --- lib/resources/command.rb | 2 +- test/resource/command_test.rb | 1 + test/runner/docker_test_container.rb | 5 ++--- test/runner/test_local.rb | 9 +++------ test/runner/test_ssh.rb | 10 ++++------ 5 files changed, 11 insertions(+), 16 deletions(-) diff --git a/lib/resources/command.rb b/lib/resources/command.rb index 002f67b61..040ea3cbf 100644 --- a/lib/resources/command.rb +++ b/lib/resources/command.rb @@ -25,7 +25,7 @@ class Cmd < Vulcano.resource(1) end def exist? - res = vulcano.run_command("type \"#{@command}\" > /dev/null") + res = vulcano.backend.run_command("type \"#{@command}\" > /dev/null") res.exit_status.to_i == 0 end end diff --git a/test/resource/command_test.rb b/test/resource/command_test.rb index 23a788015..06d073dcf 100644 --- a/test/resource/command_test.rb +++ b/test/resource/command_test.rb @@ -1,4 +1,5 @@ # encoding: utf-8 + describe command('echo hello') do its(:stdout) { should eq "hello\n" } its(:stderr) { should eq '' } diff --git a/test/runner/docker_test_container.rb b/test/runner/docker_test_container.rb index 18193e658..e567f60ae 100644 --- a/test/runner/docker_test_container.rb +++ b/test/runner/docker_test_container.rb @@ -11,9 +11,8 @@ puts '' backends = {} backends[:docker] = proc { - backend_conf = Vulcano::Backend.target_config({ 'host' => container_id }) - backend_class = Vulcano::Backend.registry['docker'] - backend_class.new(backend_conf) + opt = { 'host' => container_id } + Vulcano::Backend.create('docker', opt) } backends.each do |type, get_backend| diff --git a/test/runner/test_local.rb b/test/runner/test_local.rb index a2d095ebc..42aa2421c 100644 --- a/test/runner/test_local.rb +++ b/test/runner/test_local.rb @@ -5,15 +5,12 @@ require 'vulcano/backend' backends = {} backends[:local] = proc { - backend_conf = Vulcano::Backend.target_config({}) - backend_class = Vulcano::Backend.registry['local'] - backend_class.new(backend_conf) + Vulcano::Backend.create('local', {}).backend } backends[:specinfra_local] = proc { - backend_conf = Vulcano::Backend.target_config({ 'backend' => 'exec' }) - backend_class = Vulcano::Backend.registry['specinfra'] - backend_class.new(backend_conf) + opt = { 'backend' => 'exec' } + Vulcano::Backend.create('specinfra', opt).backend } tests = ARGV diff --git a/test/runner/test_ssh.rb b/test/runner/test_ssh.rb index 9c7b0a683..3d9ad5791 100644 --- a/test/runner/test_ssh.rb +++ b/test/runner/test_ssh.rb @@ -3,19 +3,17 @@ require_relative 'helper' require 'vulcano/backend' backends = {} -backend_conf = Vulcano::Backend.target_config({ +backend_conf = { 'target' => 'ssh://vagrant@localhost', 'key_file' => '/root/.ssh/id_rsa', -}) +} backends[:specinfra_ssh] = proc { - backend_class = Vulcano::Backend.registry['specinfra'] - backend_class.new(backend_conf) + Vulcano::Backend.create('specinfra', backend_conf).backend } backends[:ssh] = proc { - backend_class = Vulcano::Backend.registry['ssh'] - backend_class.new(backend_conf) + Vulcano::Backend.create('ssh', backend_conf).backend } tests = ARGV