Skip to content

Commit

Permalink
test if Vms and MiqTemplates are reconnectable
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Zagaynov committed Feb 1, 2018
1 parent e77a19d commit 226ac2a
Show file tree
Hide file tree
Showing 2 changed files with 721 additions and 0 deletions.
36 changes: 36 additions & 0 deletions spec/models/manager_refresh/inventory_collection_default_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# frozen_string_literal: true

describe ManagerRefresh::InventoryCollectionDefault do
before { allow(MiqServer).to receive(:my_zone) { 'My zone' } }
let(:zone) { Zone.first }

context 'Amazon' do
before do
ems = new_amazon_ems
with_vcr_data { expect { EmsRefresh.refresh(ems) }.to change { VmOrTemplate.count }.from(0) }
expect { ems.destroy }.to_not change { VmOrTemplate.count }
expect(ExtManagementSystem.count).to be_zero
end

it 'pickups existing Vm records on EMS re-adding' do
expect(Vm.count).to_not be_zero
with_vcr_data { expect { EmsRefresh.refresh(new_amazon_ems) }.to_not change { Vm.count } }
end

it 'pickups existing Template records on EMS re-adding' do
expect(MiqTemplate.count).to_not be_zero
with_vcr_data { expect { EmsRefresh.refresh(new_amazon_ems) }.to_not change { MiqTemplate.count } }
end
end

private

def new_amazon_ems
FactoryGirl.create(:ems_amazon_with_vcr_authentication, :zone => zone, :provider_region => 'eu-central-1')
end

# TODO: (zalex) DRY - put in the shared helpers
def with_vcr_data
VCR.use_cassette(described_class.name.underscore) { yield }
end
end
Loading

0 comments on commit 226ac2a

Please sign in to comment.