Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
HarikaChebrolu committed Nov 13, 2020
1 parent b43ea51 commit 0624f31
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 21 deletions.
4 changes: 4 additions & 0 deletions lib/puppet/provider/oneview_ethernet_network/c7000.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ def exists?
end
end

def self.api_version
1800
end

def create
# Checks if there is a connection template update
update_connection_template if @bandwidth
Expand Down
8 changes: 8 additions & 0 deletions spec/shared_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@
end
end

RSpec.shared_context 'shared context Oneview API 1800', a: :b do
before :each do
api_version = 1800
options = { url: 'https://oneview.example.com', user: 'Administrator', password: 'secret123', api_version: api_version }
@client = OneviewSDK::Client.new(options)
end
end

RSpec.shared_context 'shared context Hypervisor Manager', a: :b do
before :each do
api_version = 800
Expand Down
57 changes: 37 additions & 20 deletions spec/unit/provider/oneview_ethernet_network_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -133,31 +133,48 @@
provider.exists?
expect(provider.reset_default_bandwidth).to be
end
end
end

it 'should delete multiple uris' do
let(:ethernet_resource) do
Puppet::Type.type(:oneview_ethernet_network).new(
name: 'ethernet',
ensure: 'present',
data:
{
'name' => 'EtherNetwork_Test1',
'connectionTemplateUri' => nil,
'autoLoginRedistribution' => true,
'vlanId' => '202',
'networkUris' => []
},
provider: 'c7000'
)
end
api_versions = 1800
resource_types = OneviewSDK.resource_named(:EthernetNetwork, api_versions, :C7000)

describe provider_class, unit: true do
include_context 'shared context Oneview API 1800'

let(:ethernet_resource) do
Puppet::Type.type(:oneview_ethernet_network).new(
name: 'ethernet',
ensure: 'present',
data:
{
'name' => 'EtherNetwork_Test1',
'connectionTemplateUri' => nil,
'autoLoginRedistribution' => true,
'vlanId' => '202'
},
provider: 'c7000'
)
end

let(:provider) { ethernet_resource.provider }
let(:test) { resource_types.new(@client, ethernet_resource['data']) }
let(:instance) { provider.class.instances.first }

context 'given the min parameters' do
before(:each) do
ethernet_resource['data']['uri'] = '/rest/fake'
ethernet_resource['data']['networkUris'] = %w(test1 test2)
test = resource_type.new(@client, ethernet_resource['data'])
allow(resource_type).to receive(:find_by).with(anything, resource['data']).and_return([test])
allow_any_instance_of(resource_types).to receive(:retrieve!).and_return(true)
allow(resource_types).to receive(:find_by).with(anything, ethernet_resource['data']).and_return([test])
provider.exists?
allow_any_instance_of(resource_type).to receive(:bulk_delete).and_return({})
end

it 'should delete multiple uris' do
allow_any_instance_of(resource_types).to receive(:bulk_delete_check).and_return(true)
allow_any_instance_of(resource_types).to receive(:bulk_create_check).and_return(false)
expect(provider.bulk_delete_check).to be
allow_any_instance_of(resource_type).to receive(:create).and_return(ethernet_resource)
allow_any_instance_of(resource_types).to receive(:create).and_return(ethernet_resource)
end
end
end
1 change: 0 additions & 1 deletion spec/unit/provider/oneview_network_set_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
'connectionTemplateUri' => nil,
'autoLoginRedistribution' => true,
'vlanId' => '202'

},
provider: 'c7000'
)
Expand Down

0 comments on commit 0624f31

Please sign in to comment.