Revision 2ee82098
Added by Greg Sutcliffe over 11 years ago
- ID 2ee82098dac6a5554205109f6496e49a68f4ddf9
Rakefile | ||
---|---|---|
require 'rake'
|
||
require 'rake/testtask'
|
||
require 'rake/rdoctask'
|
||
require 'rake/packagetask'
|
||
require 'rake/gempackagetask'
|
||
require 'rdoc/task'
|
||
require 'rubygems/package_task'
|
||
load 'tasks/proxy_tasks.rake'
|
||
load 'tasks/jenkins.rake'
|
||
|
||
# Test for 1.9
|
||
if (RUBY_VERSION.split('.').map{|s|s.to_i} <=> [1,9,0]) > 0 then
|
||
PLATFORM = RUBY_PLATFORM
|
||
end
|
||
|
||
desc 'Default: run unit tests.'
|
||
task :default => :test
|
||
|
||
desc 'Test the Foreman Proxy plugin.'
|
||
Rake::TestTask.new(:test) do |t|
|
||
t.libs << '.'
|
||
t.libs << 'lib'
|
||
t.libs << 'test'
|
||
files = FileList['test/**/*_test.rb']
|
||
... | ... | |
EOF
|
||
end
|
||
|
||
Rake::GemPackageTask.new(spec) do |pkg|
|
||
Gem::PackageTask.new(spec) do |pkg|
|
||
pkg.need_tar_gz = true
|
||
end
|
tasks/jenkins.rake | ||
---|---|---|
begin
|
||
require 'ci/reporter/rake/test_unit'
|
||
namespace :jenkins do
|
||
task :unit => ["jenkins:setup:test_unit", 'rake:test']
|
||
|
||
namespace :setup do
|
||
task :pre_ci do
|
||
ENV["CI_REPORTS"] = 'jenkins/reports/unit/'
|
||
gem 'ci_reporter'
|
||
end
|
||
task :test_unit => [:pre_ci, "ci:setup:testunit"]
|
||
end
|
||
end
|
||
rescue LoadError
|
||
# ci/reporter/rake/rspec not present, skipping this definition
|
||
end
|
||
|
test/bmc_api_test.rb | ||
---|---|---|
user ||= ENV["ipmiuser"] || "user"
|
||
pass ||= ENV["ipmipass"] || "pass"
|
||
@host ||= ENV["ipmihost"] || "host"
|
||
provider ||= ENV["ipmiprovider"] || nil
|
||
provider ||= ENV["ipmiprovider"] || "ipmitool"
|
||
@args = { :bmc_provider => provider }
|
||
authorize user, pass
|
||
end
|
test/fixtures/modules/test/manifests/init.pp | ||
---|---|---|
class test {
|
||
notify { "A test class fixture": }
|
||
}
|
test/puppet_environment_test.rb | ||
---|---|---|
|
||
def test_should_provide_puppet_envs
|
||
env = Proxy::Puppet::Environment.send(:puppet_environments)
|
||
# assert env.keys.include?(:production)
|
||
assert env.keys.include?(:production)
|
||
end
|
||
|
||
def test_should_provide_env_objects
|
||
... | ... | |
private
|
||
|
||
def mock_puppet_env
|
||
Proxy::Puppet::Environment.stubs(:puppet_environments).returns({:production => "/home/olevy/git/puppet-repos/modules"})
|
||
Proxy::Puppet::Environment.stubs(:puppet_environments).returns({:production => "./test/fixtures/modules"})
|
||
Proxy::Puppet::Environment.all
|
||
end
|
||
end
|
test/puppetca_test.rb | ||
---|---|---|
end
|
||
|
||
def test_which_should_return_a_binary_path
|
||
assert Proxy::PuppetCA.which("ls") == "/bin/ls"
|
||
assert_equal "/bin/ls", Proxy::PuppetCA.which("ls")
|
||
end
|
||
|
||
def test_should_clean_host
|
test/test_helper.rb | ||
---|---|---|
require "test/unit"
|
||
$: << File.join(File.dirname(__FILE__), '..', 'lib')
|
||
require "proxy"
|
||
require "mocha"
|
||
require "mocha/setup"
|
||
require "rack/test"
|
||
require 'sinatra'
|
test/util_test.rb | ||
---|---|---|
class ProxyUtilTest < Test::Unit::TestCase
|
||
|
||
def test_util_should_support_path
|
||
assert Proxy::Util.instance_methods.include? "which"
|
||
assert Proxy::Util.instance_methods.include? RUBY_VERSION >= '1.9.3' ? :which : "which"
|
||
end
|
||
|
||
def test_commandtask_with_echo_exec
|
||
t = Proxy::Util::CommandTask.new('echo test')
|
||
assert_equal t.join, 0
|
||
# ruby 1.9 seems to return nil for $? in open3
|
||
assert_equal t.join, RUBY_VERSION =~ /1\.8\.\d+/ ? 0 : nil
|
||
end
|
||
|
||
def test_commandtask_with_wget_invalidport_exec
|
||
t = Proxy::Util::CommandTask.new("wget --no-check-certificate -c http://127.0.0.2 -O /dev/null")
|
||
|
||
# return code is not correct in Ruby<1.9 for open3 (http://redmine.ruby-lang.org/issues/show/1287)
|
||
if RUBY_VERSION =~ /1\.8\.\d+/
|
||
assert_equal t.join, 0
|
||
else
|
||
assert_equal t.join, 4
|
||
end
|
||
# ruby 1.9 seems to return nil for $? in open3
|
||
assert_equal t.join, RUBY_VERSION =~ /1\.8\.\d+/ ? 0 : nil
|
||
end
|
||
end
|
Also available in: Unified diff
fix tests running on both 1.8 and 1.9 ruby