From 3c70945c7edb60a6cd5f239d1cf111c81ece16f6 Mon Sep 17 00:00:00 2001 From: Beni Cherniavsky-Paskin Date: Thu, 21 Dec 2017 20:05:30 +0200 Subject: [PATCH] Check tag mapping in VCR refresher specs https://bugzilla.redhat.com/show_bug.cgi?id=1506404 --- .../amazon/aws_refresher_spec_common.rb | 30 +++++++++++++++---- .../refresher_inventory_object_spec.rb | 2 ++ .../cloud_manager/vcr_specs/refresher_spec.rb | 2 ++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/spec/models/manageiq/providers/amazon/aws_refresher_spec_common.rb b/spec/models/manageiq/providers/amazon/aws_refresher_spec_common.rb index 389f48a1b..0df5b36ff 100644 --- a/spec/models/manageiq/providers/amazon/aws_refresher_spec_common.rb +++ b/spec/models/manageiq/providers/amazon/aws_refresher_spec_common.rb @@ -81,7 +81,7 @@ def assert_common assert_specific_orchestration_stack assert_network_router assert_relationship_tree - # assert_specific_tags_on_vm + assert_specific_labels_on_vm end def assert_specific_flavor @@ -1386,9 +1386,27 @@ def assert_relationship_tree expect(@ems.descendants_arranged).to match_relationship_tree({}) end - # TODO: Add some real specs here - # def assert_specific_tags_on_vm - # vm = ManageIQ::Providers::Amazon::CloudManager::Vm.where(:name => "EmsRefreshSpec-PoweredOn-Basic3").first - # expect(vm.tags).to be_empty - # end + def assert_specific_labels_on_vm + vm = ManageIQ::Providers::Amazon::CloudManager::Vm.find_by(:name => "ladas_test_5") + expect(vm.labels).to include( + an_object_having_attributes( + :name => "EmsRefreshSpecResourceGroupTag", + :value => "EmsRefreshSpecResourceGroupTagValue", + :source => "amazon" + ) + ) + end + + def create_tag_mapping + @tag_mapping = FactoryGirl.create(:tag_mapping_with_category, + :label_name => "EmsRefreshSpecResourceGroupTag") + end + + # Tests can assert this if they called create_tag_mapping before refresh. + def assert_mapped_tags_on_vm + vm = ManageIQ::Providers::Amazon::CloudManager::Vm.find_by(:name => "ladas_test_5") + expect(vm.tags.count).to eq(1) + expect(vm.tags.first.category).to eq(@tag_mapping.tag.classification) + expect(vm.tags.first.classification.description).to eq("EmsRefreshSpecResourceGroupTagValue") + end end diff --git a/spec/models/manageiq/providers/amazon/cloud_manager/vcr_specs/refresher_inventory_object_spec.rb b/spec/models/manageiq/providers/amazon/cloud_manager/vcr_specs/refresher_inventory_object_spec.rb index 51047a9e5..35c1bc5ce 100644 --- a/spec/models/manageiq/providers/amazon/cloud_manager/vcr_specs/refresher_inventory_object_spec.rb +++ b/spec/models/manageiq/providers/amazon/cloud_manager/vcr_specs/refresher_inventory_object_spec.rb @@ -17,6 +17,7 @@ context "with settings #{settings}" do before(:each) do stub_refresh_settings(settings) + create_tag_mapping end it "will perform a full refresh" do @@ -32,6 +33,7 @@ end assert_common + assert_mapped_tags_on_vm end end end diff --git a/spec/models/manageiq/providers/amazon/cloud_manager/vcr_specs/refresher_spec.rb b/spec/models/manageiq/providers/amazon/cloud_manager/vcr_specs/refresher_spec.rb index 41c4baceb..e19ed395d 100644 --- a/spec/models/manageiq/providers/amazon/cloud_manager/vcr_specs/refresher_spec.rb +++ b/spec/models/manageiq/providers/amazon/cloud_manager/vcr_specs/refresher_spec.rb @@ -17,6 +17,7 @@ context "with settings #{settings}" do before(:each) do stub_refresh_settings(settings) + create_tag_mapping end it "will perform a full refresh" do @@ -33,6 +34,7 @@ end assert_common + assert_mapped_tags_on_vm end end end