Skip to content

Commit

Permalink
Test the end-to-end refresh in the refresher_spec
Browse files Browse the repository at this point in the history
Instead of just testing parse with vcr, then saving no inventory we can
run the full EmsRefresh.refresh in the vcr block so we can test
relationship links created in save_ems_inventory in the future.
  • Loading branch information
agrare committed Oct 26, 2017
1 parent 56cf327 commit 6efc540
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,24 @@
:name => "LXCA",
:hostname => "https://10.243.9.123",
:port => "443",
:ipaddress => "https://10.243.9.123:443")
:ipaddress => "https://10.243.9.123:443").tap do |ems|
ems.authentications << auth
end
end

let(:targets) { [ems] }
let(:refresher) { described_class.new(targets) }
it 'will perform a full refresh' do
2.times do # Run twice to verify that a second run with existing data does not change anything
result = VCR.use_cassette("#{described_class.name.underscore}") do
EmsRefresh.refresh(ems)
end

it 'will parse the legacy inventory' do
ems.authentications = [auth]
ems.reload

result = VCR.use_cassette("#{described_class.name.underscore}_parse_legacy_inventory") do
refresher.parse_legacy_inventory(ems)
assert_table_counts
end

expect(result[:physical_servers].size).to eq(3)
end

it 'will save the inventory' do
ems.authentications = [auth]

refresher.save_inventory(ems, nil, {})
end

it 'will execute post_process_refresh_classes' do
expect(refresher.post_process_refresh_classes).to eq([])
def assert_table_counts
expect(PhysicalServer.count).to eq(3)
end
end

0 comments on commit 6efc540

Please sign in to comment.