Skip to content

Commit

Permalink
Check tag mapping in VCR refresher specs
Browse files Browse the repository at this point in the history
  • Loading branch information
cben committed Dec 21, 2017
1 parent b7044b0 commit 3c70945
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
30 changes: 24 additions & 6 deletions spec/models/manageiq/providers/amazon/aws_refresher_spec_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -32,6 +33,7 @@
end

assert_common
assert_mapped_tags_on_vm
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -33,6 +34,7 @@
end

assert_common
assert_mapped_tags_on_vm
end
end
end
Expand Down

0 comments on commit 3c70945

Please sign in to comment.