Sha256: 30980a77a0cb8e2a3f59f788554be9b9534d816f29826142d1a207a7ea18cd19

Contents?: true

Size: 1.97 KB

Versions: 3

Compression:

Stored size: 1.97 KB

Contents

require 'spec_helper'

describe Heirloom do

    before do
      @config_mock = double 'config'
      @logger_mock = double 'logger'
      @config_mock.should_receive(:logger).and_return(@logger_mock)
      @destroyer = Heirloom::Destroyer.new :config => @config_mock,
                                           :name   => 'tim',
                                           :id     => '123'
    end

    before do
      @logger_mock.stub :info => true
      @reader_mock = mock 'archive reader'
      @destroyer.stub :reader => @reader_mock
      @reader_mock.should_receive(:get_bucket).
                  with(:region => 'us-west-1').
                  and_return 'bucket-us-west-1'


      @s3_destroyer_mock = mock 's3 destroyer'
      Heirloom::Destroyer::S3.should_receive(:new).
                              with(:config => @config_mock,
                                   :region => 'us-west-1').
                              and_return @s3_destroyer_mock
      @s3_destroyer_mock.should_receive(:destroy_file).
                        with :key_name   => '123.tar.gz',
                             :key_folder => 'tim',
                             :bucket     => 'bucket-us-west-1'
      @sdb_mock = mock 'sdb'
      @destroyer.stub :sdb => @sdb_mock
      @sdb_mock.should_receive(:delete).with 'heirloom_tim', '123'
    end

    it "should destroy the given archive" do
      Kernel.should_receive(:sleep).with 3
      @sdb_mock.should_receive(:domain_empty?).with('heirloom_tim').
               and_return true
      @sdb_mock.should_receive(:delete_domain).with('heirloom_tim')
      @destroyer.destroy :regions => ['us-west-1'],
                         :keep_domain => false
    end

    it "should destroy the given archive but keep the sbd domain" do
      @sdb_mock.should_receive(:domain_empty?).exactly(0).times
      @sdb_mock.should_receive(:delete_domain).exactly(0).times
      @destroyer.destroy :regions     => ['us-west-1'],
                         :keep_domain => true
    end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
heirloom-0.6.1 spec/archive/destroyer_spec.rb
heirloom-0.6.0rc1 spec/archive/destroyer_spec.rb
heirloom-0.5.0rc4 spec/archive/destroyer_spec.rb