Sha256: 4a0ebff744a681d289b705555df792224ab7e18ad8f7305127f47765f8136955

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

$:.unshift(File.join(ENV['AWS_HOME'], "app"))
require 'test/unit'
require 'MockAWS/clock'
require 'logger_factory'
require 'configuration'
require 'pool_configuration'
require 'aws_context'
require 'pp'

# Test that the standard policy classes can be created, and have the
# right class names.  This tests the dynamic loading of the policy code.
# It tests the job and resource policies, as well as the fixed policy.
class FixedPolicyTests < Test::Unit::TestCase
  def startup(pool)
    LoggerFactory.setup("/tmp/test.out")
    logf = LoggerFactory.create(:file)
    config_files = ['aws-config.ini', 'default-config.ini', 'test-config.ini']
    Cloudmaster::Configuration.setup_config_files(config_files)
    tc = Cloudmaster::Configuration.new([], [pool])
    cfg = Cloudmaster::PoolConfiguration.new(tc.aws, tc.default, tc.pools[0])
    reporter = Cloudmaster::Reporter.setup(cfg[:name], logf)
    cfg[:ami_id] = "ami-08856161"
    @cfg = cfg
    AwsContext.setup(:mock, logf)
    @pool = Cloudmaster::InstancePool.new(reporter, @cfg)
    @policy = Cloudmaster::PolicyFactory.create(@cfg[:policy], reporter, @cfg, @pool)
  end

  def test_primes
    startup(:primes)
    assert_equal(Cloudmaster::PolicyJob, @policy.class)
  end

  def test_fib
    startup(:fib)
    assert_equal(Cloudmaster::PolicyResource, @policy.class)
  end

  def test_fixed_policy
    startup(:fixed)
    assert_equal(Cloudmaster::PolicyFixed, @policy.class)
  end

  def test_bad_policy
    assert_raise(LoadError) do
      startup(:bad)
      Cloudmaster::PolicyDefault
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
staugaard-cloudmaster-0.1.1 test/fixed-policy-tests.rb