-
Notifications
You must be signed in to change notification settings - Fork 896
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test if Vms and MiqTemplates are reconnectable
- Loading branch information
Alexander Zagaynov
committed
Feb 2, 2018
1 parent
a3631c3
commit a855726
Showing
2 changed files
with
722 additions
and
0 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
spec/models/manager_refresh/inventory_collection_default_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
describe ManagerRefresh::InventoryCollectionDefault do | ||
it 'pickups existing Vm and MiqTemplate records on Amazon EMS re-adding' 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 } | ||
|
||
aggregate_failures do | ||
expect(Vm.count).to_not be_zero | ||
expect(MiqTemplate.count).to_not be_zero | ||
expect(ExtManagementSystem.count).to be_zero | ||
end | ||
|
||
ems = new_amazon_ems | ||
|
||
with_vcr_data do | ||
expect { EmsRefresh.refresh(ems) } | ||
.to change { VmOrTemplate.distinct.pluck(:ems_id) }.from([nil]).to([ems.id]) | ||
.and change { VmOrTemplate.count } .by(0) | ||
.and change { MiqTemplate.count } .by(0) | ||
.and change { Vm.count } .by(0) | ||
end | ||
end | ||
|
||
private | ||
|
||
def new_amazon_ems | ||
FactoryGirl.create(:ems_amazon_with_vcr_authentication, :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 |
Oops, something went wrong.