summaryrefslogtreecommitdiffstats
path: root/spec/unit/provider
diff options
context:
space:
mode:
Diffstat (limited to 'spec/unit/provider')
-rw-r--r--spec/unit/provider/vpp_service/vpp_spec.rb46
1 files changed, 46 insertions, 0 deletions
diff --git a/spec/unit/provider/vpp_service/vpp_spec.rb b/spec/unit/provider/vpp_service/vpp_spec.rb
new file mode 100644
index 0000000..1d9d9ba
--- /dev/null
+++ b/spec/unit/provider/vpp_service/vpp_spec.rb
@@ -0,0 +1,46 @@
+require 'puppet'
+require 'puppet/provider/vpp_service/vpp'
+require 'spec_helper'
+
+provider_class = Puppet::Type.type(:vpp_service).provider(:vpp)
+
+describe 'Puppet::Type.type(:vpp_service).provider(:vpp)' do
+
+ let :vpp_attrs do
+ {
+ :name => 'vpp service config',
+ :pci_devs => '0000:00:07.0',
+ :ensure => 'present',
+ :state => 'up',
+ :copy_kernel_nic_ip => 'false',
+ }
+ end
+
+ let :resource do
+ Puppet::Type::Vpp_service.new(vpp_attrs)
+ end
+
+ let :provider do
+ provider_class.new(resource)
+ end
+
+ describe 'on create' do
+ it 'should call service restart' do
+ provider.expects(:vpp_pre_config)
+ provider.expects(:configure_vpp_interfaces)
+ provider.expects(:systemctlcmd).with('restart', 'vpp')
+ provider.expects(:systemctlcmd).with('enable', 'vpp')
+ provider.expects(:systemctlcmd).with('is-enabled', 'vpp')
+ provider.expects(:systemctlcmd).with('is-active', 'vpp')
+ provider.create
+ end
+ end
+
+ describe "when changing state" do
+ it 'should change state' do
+ provider.stubs(:get_int_prefix).returns('GigabitEthernet0/7/0')
+ provider.expects(:vppctlcmd).with('set int state', 'GigabitEthernet0/7/0', 'down')
+ provider.state = 'down'
+ end
+ end
+end \ No newline at end of file