Last active
August 29, 2015 14:08
-
-
Save gaudenz/5669279915c8cd54a1f4 to your computer and use it in GitHub Desktop.
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
require 'spec_helper' | |
describe Puppet::Type.type(:vs_port).provider(:ovs) do | |
before :each do | |
# Set up stubs for provider checks | |
# described_class.stubs(:command).with(:vsctl).returns '/usr/bin/ovs-vsctl' | |
# Set up command stubs, this does not seem to work, or the arguments are wrong? | |
described_class.stubs(:vsctl).with('get' 'Port' 'eth0', 'interfaces').returns('[cec1ef5a-6281-41d0-8d8a-39610f8f89aa]') | |
# provider.class.stubs(:vsctl).with([]).returns('') | |
end | |
let(:resource) do | |
Puppet::Type.type(:vs_port).new( | |
:name => 'eth0', | |
:interface => 'eth0', | |
:bridge => 'br0', | |
:ensure => :present, | |
:provider => provider, | |
) | |
end | |
let(:provider) { described_class.new(:name => 'eth0') } | |
describe 'create' do | |
it 'creates a port' do | |
# this is weird, but without this the resource is not full defined, the interfaces does not have a value | |
resource[:interface] | |
# resource[:interface] = ['eth0'] | |
provider.expects(:vsctl).with('--', '--id=@iface0', 'create', 'Interface', 'name=eth0', '--', 'add-port', 'br0', 'eth0', 'interfaces=@iface0') | |
provider.expects(:vsctl).with('--if-exists', 'get', 'Port', 'eth0', 'interfaces') | |
# provider.expects(:exists?).returns(true) | |
expect(provider.create).to be_truthy | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment